Easy Extend



   




1. Installation

1.1 Prerequisites

For EasyExtend 3.0 a prior installation of Python 2.5 is required. This is the only Python version currently supported by EasyExtend.

1.2 Installers

Installers for the latest version of EasyExtend can be found here. The Windows just needs to be downloaded and opened. For source distributions in zip or tar.gz format, unpack them and type

                $ python setup.py install

Notice that source distributions for non Win 32 systems compiles and installs an extension module called cyTrail.c based on code written in Cython. This module is optional and serves optimization purposes only. It is not required for running EasyExtend.

1.3 Optional installations

1.3.1 psyco

I strongly recommend installing psyco as well. Psyco is a JIT compiler for Python and it might speed up lexing/parsing/transformation times by a factor of 3. EasyExtend uses a decorator that puts certain functions under supervision of psyco when it is installed. Otherwise the decorator returns just the the unsupervised functions.

1.4 After the installation

Change directory and point to site-packages. In EasyExtend 3.0 you will see roughly the following source tree:

  [site-packages]+-[EasyExtend]+-[langlets]                            
                                  +- Grammar
                                  +- Token
                                  +- fs  
                                  +- __init__.py  
                                  +- cst.py  
                                  ....

                                  +- [gallery]   
                                      +- __init__.py
                                      +- conf.py
                                      +- langlet.py                                               
                                      +- [lexdef]
                                          +- Token
                                          +- Token.ext
                                          +- __init__.py
                                          +- lex_nfa.py
                                          +- lex_symbol.py
                                          +- lex_token.py

                                      +- [parsedef]
                                          +- Grammar
                                          +- Grammar.ext
                                          +- __init__.py
                                          +- parse_nfa.py
                                          +- parse_symbol.py
                                          +- parse_token.py
                                      +- [tests]
                                 
+- [grammar_langlet]                            
                                  +- [zero]
                               +- [langlet_template]
                               +- [trail]                               
                               +- [util]   

1.5  Sanity check

A consoletest is implemented that checks some basic properties of EasyExtend.

cd to EasyExtend/tests and type:

         $ python run_consoletest.py

2. First Session

For each langlet a langlet specific console is immediately available that can be used to checkout user defined syntax. A few langlets are always dsirtibuted with EasyExtend. One of them is called Gallery. The Gallery langlet contains a set of language definitions not available in Python.

cd to EasyExtend/langlets/gallery and type:

         $ python run_gallery.py

__________________________________________________________________________________

 gallery

 On Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
__________________________________________________________________________________

gal>
gal> def test(a):
....    switch a:
....            case 0:
....                    print "nok"
....            case 1:
....                    print "ok"
....    else:
....            print "default"
....
gal> test(0)
nok
gal> test(1)
ok
gal> test(2)
default
gal> quit
__________________________________________________________________________________


Instead of running commands within a console you might also create a script. In case of Gallery scripts have the *.gal extension.


EasyExtend/langlets/gallery/demo.gal
def test(a):
    switch a:
        case 0:
            print "nok"
        case 1:
            print "ok"
    else:
        print "default"

if __name__ == '__main__':
   test(1)

In order to run the module from the command line type

        $ python run_gallery.py demo.gal

or you might import demo.gal within your console session:

gal> import demo
gal> demo.test(1)
ok


Learn more about