Felix syntax grammars now support groups. For example: nlist := lpar name (,name)* rpar =># "`(cons ,_2 ,(map car _3))";
First, note that ( and ) must be recognised as tokens with the special predefined nonterminals lpar, rpar, because now the symbols ( and ) have a new meaning. Now, see that ( and ) define a new nonterminal: __grp_42 := , name =># "`(,_2)"; whose name is replaced in the original production: nlist := lpar name __grp_42* rpar =># "`(cons ,_2 ,(map car _3))"; Now, examine closely the generated user action: it is always a list of the nonterminals of the group. Take care noting that special symbols like 'lpar' are nonterminals! For this reason __grp_42 returns a list of a list of a single name, instead of a list of names, so we map 'car' over that list to make a list of names instead (car is Schemish for 'hd', the first element of a list). [Flame: I thought scheme was supposed to be good at lists, but Ocaml is miles better: lack of pattern matching in Scheme is a serious deficiency .. I'm temped to add it to Ocs Scheme.] -- 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