bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Named symbol references


From: Akim Demaille
Subject: Re: [PATCH] Named symbol references
Date: Wed, 28 Jan 2009 17:52:16 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux)

>>> "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); }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]