[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Akim Demaille] Naming the symbols
From: |
Akim Demaille |
Subject: |
Re: [Akim Demaille] Naming the symbols |
Date: |
Tue, 12 Jul 2005 11:10:58 +0200 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
>>> "Paul" == Paul Eggert <address@hidden> writes:
> Akim Demaille <address@hidden> 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.
- Re: [Akim Demaille] Naming the symbols,
Akim Demaille <=