lua-users home
lua-l archive

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


> Well not perfect :) The problem is that to add the sugar,
> you have to parse the input stream according to your 
> extended grammar

There's no way around that, of course. Sugar requires local parsing.

> apply rewriting rules to the subtrees
> corresponding to reductions, and then rewrite the resultant
> modified trees out again as token streams.

Lua's parser does not use trees. And I think that it is simpler to let
it raise errors, instead of doing syntax checking for sugar.
 
> In other words, you have to duplicate the whole parser
> and modify it, and you also can't add new token types
> since you're reading a stream of tokens produced
> by the standard lexer.

Not quite true: Luckily, the lexer does not raise errors on single-char
tokens that it does not understand and so you can use those for your own
purposes, but you're still only allowed to generate good tokens.

--lhf