[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: sugarcubes for me.my.self.and.I [Re: Lua OOP initiative]
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 17 Jan 2005 09:18:52 -0200
> 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.