[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Named symbol references
From: |
Alex Rozenman |
Subject: |
Re: [PATCH] Named symbol references |
Date: |
Wed, 28 Jan 2009 20:19:10 +0200 |
Hi Akim,
Thank you for your response. Unfortunately I missed old discussions about
this topic. Issues of syntax are always hard.
I totally agree about using of parens '(' and ')'; it's better to leave them
alone.
I like the "rhs:exp" syntax, I also considered it, but it looks to me a
little bit ridiculous to the require trailing semicolon
in THIS case - looks unrelated.
Using of dollars in alias declarations has, IMHO, some advantages, for
example when doing incremental
search with emacs. I have, actually, a version supporting exp(=$rhs) syntax,
but from other side what about
@rhs - they will not be "declared" ?
Another possibility is using of '='. For example:
exp : left=exp '+' right=exp;
or
exp : $left=exp '+' $right=exp;
or
exp : exp=$left '+' exp=$right;
It is very important to keep clarity in the grammar text. The latest one
looks pretty clear.
I would also like to be able to use default names when there are no
> ambiguities, say
> stmt: lvalue "=" exp { $stmt = new Assignment(@stmt, $lvalue, $exp); }
>
I already implemented it in the submitted patch :) How do you know ?
Best regards, and thank you,
Alex
On Wed, Jan 28, 2009 at 6:52 PM, Akim Demaille
<address@hidden>wrote:
> >>> "AR" == Alex Rozenman <address@hidden> writes:
>
> > Hello bison team.
>
> Hi Alex,
>
> It is great news to see that someone picked up the ball about this
> topic. I have Cc'd a mailing list on which a similar patch from
> Benoît Perrot had been discussed a while ago. I would like to find
> the best compromise bw the difference approaches.
>
> Joel, I'm sorry to involve you in, but you demonstrated good taste in
> syntactic issues in Bison, so your opinion, if you have some time,
> would be great.
>
> > I would like to submit a patch adding some kind of named symbol
> references
> > in input grammar. It looks like this:
>
> > tchk_definition
> > : SETUP(kw) '(' timing_check_event(dat) ',' timing_check_event(ref)
> ','
> > timing_check_limit(lmt) notify_register_arg(reg) ')'
> > {
> > vcLinkTchk(accSetup, $ref, $dat, $lmt, $reg, vsc_scopeG,
> > vsc_specifyG, $kw.lineNum, $kw.srcInfo);
> > }
>
> > @name (location info) is also supported.
>
> > This functionality has been already tested and used in my company
> > for many (5+) years, the original change was done on 1.75
> > version. There are some big scale parsers (Verilog, Verilog 2001,
> > VHDL) implemented using this syntax. I understand that at least,
> > documentaion and tests are missing. This is my first time I am
> > trying to contribute to bison, so please provide me additional info
> > about the process.
>
> It is funny that you have chosen this syntax, because I seem to recall
> that it was one of the proposals that were made when the topic came
> out. How did you come up with it?
>
> I have to admit I don't like it too much. My main objection against
> it is that it prevents us from using ( ) in the future for grouping if
> we happen to support some form of EBNF-like extensions. It is true
> though that we already have a problem with | since in EBNF
>
> a -> b | c { action }
>
> would refer two a single rule with a single action, whereas Bison
> would see two rules :(
>
>
> I would have loved to use ":" as in
>
> exp: rhs:exp "+" lhs:exp
>
> or even
>
> res:exp : rhs:exp "+" lhs:exp
>
> but then, of course we have a problem with the colon, especially since
> ending rules with a semicolon is not required. Maybe there is a way
> out if we require the grammars that want to use this feature to end
> all their rules with ; (which is something I would really like to
> require...). I should experiment to see if there is a means for the
> Bison grammar to support this. I believe Benoît made several
> experiments in this area.
>
> I prefer to see the name first (as in "varname : type"), but others
> have proposed the opposite.
>
> If used the other way round, we could use $ as a separator:
>
> exp$res: exp$lhs "+" exp$rhs
>
> which has the (weak) advantage of introducing the alias exactly as it
> will be used. Since anyway we have to find a character, why not $?
>
> I would also like to be able to use default names when there are no
> ambiguities, say
>
> stmt: lvalue "=" exp { $stmt = new Assignment(@stmt, $lvalue, $exp); }
>
--
Best regards,
Alex Rozenman (address@hidden).