lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Splendid that in lpeg 0.6 we can now use string table keys to
represent nonterminals. Is there no cunning trick with function
environments that would give us an lpeg 0.7 in which nonterminals
could be used as themselves on the right hand side of productions,
instead of having to wrap them in quotes with a prepended lpeg.V?
It would be so much nicer to be able to write

{ ....
Exp = .....
Term = Number + Open*Exp*Close;
.....}

instead of
{ ....
Exp = .....
Term = Number + Open*lpeg.V"Exp"*Close;
.....}

In fact I would not mind a notation like
{ ....
[Exp] = .....
[Term] = Number + Open*Exp*Close;
.....}

with keys that are patterns rather than integers or strings.

How about a notation
{ ....
Exp := .....
Term := Number + Open*Exp*Close;
.....}
where the := token tells the parser to treat the following
expression in a recursive environment? Maybe that could have other uses?

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/