On Sat, 2007-08-25 at 13:12 -0700, Erick Tryzelaar wrote:
> I'm playing around with the dssl support and it's really cool. I'm
> running into some issues though. I'm toying around with the idea of
> list comprehensions, but I'm having trouble actually getting it
> implemented. Here's my toy code:
> 
> comprehensions.flx:
> syntax foo {
>   satom := [ sexpr ] =># (List::list _2);

You need:

        satom := lqsb sexpr rsqb =># ....

The [ ] brackets are meta-symbols, (to be) used for parameterised
nonterminals like:

        expr[plus] := expr[plus] + expr[mult] =># ...

where plus, mult are Dypgen priorities. However Dypgen is bugged with
respect to run time priorities, so this feature is incomplete and
unused. Look at the base grammar:

opt_prio:
  | LSQB NAME RSQB { `Priority (snd $2) }
  | { `Default }

dyprod:
   | opt_private NAME opt_prio COLONEQUAL dyalts SEMI

for example.

If you look further in lpsrc/flx_parser.ipk you will find replacement
names for the used metasymbols, as well as the names of base
nonterminals, here:

///////////////////////////////////////////////////////
/* low level non terminals */
%constructor Obj_sexpr %for sname sliteral 

/* literals */
%constructor Obj_sexpr %for sinteger sfloat sstring scstring strue
sfalse
%constructor Obj_sexpr %for strint strfloat strstring strtrue strfalse

/* patterns */
%constructor Obj_sexpr %for sintegral

/* tokens replacements for special symbols used in productions */
%constructor Obj_sexpr %for star plus quest suser10token sident
%constructor Obj_sexpr %for suserlbtoken suserrbtoken
%constructor Obj_sexpr %for lbrace rbrace lpar rpar lsqb rsqb 
%constructor Obj_sexpr %for ssemi comma colon vbar

/* nothing*/
%constructor Obj_sexpr %for sepsilon
%constructor Obj_sexpr %for strepsilon
/////////////////////////////////////////////////

and also here:

/////////////////////////////////////
/* identifiers which aren't keywords */
sname: NAME { 0,slift (fst $1),Sstring (snd $1) }

/* 
replacements for * + and ? to be used in productions,
since these symbols have special meansings as
list, non-empty list, and optional respectively
*/
star: STAR { 0,slift $1,Snull }
plus: PLUS { 0,slift $1,Snull }
quest: QUEST { 0,slift $1,Snull }
sident: IDENT { 0,slift $1,Snull }

lbrace: LBRACE { 0,slift $1,Snull }
rbrace: RBRACE { 0,slift $1,Snull }
lpar: LPAR { 0,slift $1,Snull }
rpar: RPAR { 0,slift $1,Snull }
lsqb: LSQB { 0,slift $1,Snull }
rsqb: RSQB { 0,slift $1,Snull }

ssemi: SEMI { 0,slift $1,Snull }
comma: COMMA { 0,slift $1,Snull }
colon: COLON { 0,slift $1,Snull }
vbar: VBAR { 0,slift $1,Snull }
strue: TRUE { 0,slift $1,Snull }
sfalse : FALSE { 0,slift $1,Snull }

strtrue: TRUE { 0,slift $1,Sstring "true" }
strfalse : FALSE { 0,slift $1,Sstring "false" }

/* 
a definite non-terminal for a sequence of no tokens,
since the production syntax cannot parse an empty
production at the moment 
*/
sepsilon: | {0,dummysr,Snull }
strepsilon: | {0,dummysr,Sstring "" }

..... (more in the real file)

//////////////////////////////////////


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to