The new parsing system is coming along well.
Many of the test cases actually compile and run.
So here's an overview and comments on the future.

Felix can do stuff like this:

syntax mysyn {
  sswapop := <-> =># "'_swap";
  sassignment := sexpr sswapop sexpr ; =># 
    "`(ast_call ,_2 (,_1 ,_3))";
}

open syntax mysyn;

What this does is create a new syntax package 'mysyn'
which can then be opened to allow the new grammar extensions
to be effective.

I may sometimes call these packages DSSLs or 
Domain Specific Sub Languages. The above DSSL adds
a new assignment form which can recognize

        a <-> b;

and maps it to

        call _swap (a,b);

At present almost the whole Felix grammar is coded
as an extension in the library. The user actions
here are written after =># and are Scheme programs
encoded as strings. They're executed by the parser
when a production is reduced, and return a Scheme value.
These values are then translated to Felix AST terms via
an intermediate S-expression form coded in Ocaml.

Why Scheme?
-----------

I chose Scheme because it's supposed to be good at symbol
processing. The dynamic typing is both an advantage and
a pain.

Extensions
----------

At present there is one extension: you can write

        nonterm *
        nonterm +
        nonterm ?


for a list of nonterm, a nonempty list, and an optional
term, respectively. This saves adding gratuitous symbols
and writing the recursions out. 

I plan to add some more: extend *,+,? so you can write

        x ( , x ) *

for a comma separated list of x's for example.

Another extension is to upgrade the syntax to the Felix
GLR syntax which allows:

        name: nonterm

as a symbol, so you can use the name instead of the
position number like _2 which has to be used at present.

A more important extension is to allow:

        sexpr := sexpr .. sexpr =># range (_1, _2);

that is, allow a user action to be a *Felix* term
instead of a Scheme term. In this case the idea
is we just parse it, and use the Scheme value returned
by reducing it as the user action (roughly ..)


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to