Le 26/05/2010 18:55, Attila Szegedi a écrit :
On 2010.05.26., at 18:22, Rémi Forax wrote:
In the same time, users don't want to understand parsers/grammar limitations.
Users want things like optional semicolon like in Javascript or Groovy,
Optional semicolon is exactly the main bane of anyone who wants to write a
conventional grammar for JavaScript - newline is either whitespace, or
significant, depending on context. Bah :-)
It's always like that - implementers have to work hard to make something easy
and convenient for users.
Attila.
Again, Tatoo can help here :)
This is easy to implement something like that if before starting to
recognize a token
the lexer ask the parser what are the tokens that doesn't lead to an error
and only enables the corresponding automata.
This is the default behavior of Tatoo lexer.
So with this grammar:
tokens:
...
eoln = '(\r)?\n'
blanks:
space = '( |\t|\r|\n)'
eoi = 'eoln'
| ';'
;
instr = assignment eoi
| ...
The automata corresponding to eoln is only activated at the end of each
instruction,
and because eoln have priority over space, the lexer will recognize eoln
instead of space
for input '\n'.
see section 3.2 of
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.96.5092&rep=rep1&type=pdf
(and please don't read the other section, Tatoo has changed since :)
Rémi
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.