>>> "Paul" == Paul Eggert <[EMAIL PROTECTED]> writes:
> Akim Demaille <[EMAIL PROTECTED]> writes:
>> - use this syntax, it is human readable and natural.
> I dunno, I find it a bit hard to read, with ":" being overloaded so
> seriously, not only in the grammar, but also in your C++ code. There
> sure are a lot of colons there.
Yep. But of course there is code between braces that also help
keeping the rhythm.
> As long as you're redoing the syntax, why not go all the way and use
> "->" rather than ":" to separate the head of the grammar from the
> body? Then, you can allow your extension only for new-style grammar
> rules that use "->". Something like this:
> r:exp ->
> "if" c:exp "then" t:exp
> { r = new ast::IfExp (c, t); }
>> "if" c:exp "then" t:exp "else" e:exp
> { r = new ast::IfExp (c, t, e); }
> ;
> You can insist on a terminating ";" here, of course.
I resisted this idea because I don't like when TMTOWTDI. But why not
indeed.
But then, why -> instead of the more traditional `::='. Both are OK.
> I'd think this extension would be LALR(1), if you play your cards right.
That's not clear to me, if you consider things like
exp: exp '+' exp
exp -> exp '-' exp
we have the same problem: where does the first rule end. I still
think dropping the scanner hacks and moving towards using the GLR
parser is a better road. Whatever the syntax we choose. And then,
there is no longer any need to define two syntax for rules, we merely
define several syntax for the `->' token.