On Sat, 2007-07-21 at 14:37 +1000, skaller wrote:
> Felix syntax grammars now support groups. For example:
> 
>   nlist := lpar name (,name)* rpar =># "`(cons ,_2 ,(map car _3))";

just so you know what I'm not trying to do,
I'm trying to implement SQL as defined by:

http://www.sqlite.org/lang.html

The method of processing SQL is to call a function with a string.
The string will be constructed like:

        s := select all "name", "address" from "mytable";

The SQL keywords will we written as names (not keywords!).
The table and row names etc remain strings.

The user action will construct a string like:

        s := "select all name, address from mytable";

which is fed to the SQL processor. The difference between
this format and just making the string is that it is
syntax checked by Felix, and invalid SQL syntax will be
rejected whilst parsing.

Since I know 'almost no' SQL I may have many misunderstandings here :)

A better approach would allow combinators. For an example consider
how Felix handles regexps:

        regexp a = ...
        regexp b = ...
        regexp c = a | b; // alternation combinator

However I don't know enough SQL to know what combinators might 
be useful.

>From the parsing viewpoint, the interesting thing is how
to enable an efficient parse, whilst doing tricks with
magic names.

Recall what Felix does:

  select_opt := "all" | "distinct" | sepsilon;

  sql_statement := 
    "select" select_opt result
    ("from" table_name (, table_name)*)?
     ("where" sql_expr) 
   ....
    =>#  "";


Where a string is written like "select" Felix first recognizes
any name (identifier). Then it checks the name is the given
string and raises Giveup if they're not equal.



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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to