help-bison
[Top][All Lists]
Advanced

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

Re: how to get left hand side symbol in action


From: r0ller
Subject: Re: how to get left hand side symbol in action
Date: Thu, 9 May 2019 17:52:56 +0200 (CEST)

Well, I can only agree:)

-------- Eredeti levél --------
Feladó: Christian Schoenebeck < address@hidden (Link -> mailto:address@hidden) >
Dátum: 2019 május 9 13:23:13
Tárgy: Re: how to get left hand side symbol in action
Címzett: address@hidden (Link -> mailto:address@hidden)
On Donnerstag, 9. Mai 2019 08:50:27 CEST Akim Demaille wrote:
> > Perhaps a variation of $ and @ that gives access to the name,
>
> I am very uncomfortable with this. Symbol names are technical details,
> most of the time they are irrelevant to the end user, just like the
> the user of a piece of software does not care about the names of the
> functions: that's a implementation detail.

That's actually a very common required feature in practice. The main use cases
are:

1. Auto completion features

2. Human friendly error messages

I do need these features for almost all parsers, hence for years (since not
available directly with Bison) I have a huge bunch of code on top of the
internal skeleton code to achieve them. With the obvious problems:

- since based on skeleton internals, that extra code might break with new
Bison version (which it did already several times)

- since the generated parser tables are a compressed representation of the
grammar, designed just to resolve grammar rules efficiently at runtime,
hence information is missing for the tasks above that must be extra polated
with additional custom code to achieve those feature ATM

> In addition, tokens have several names: the identifier, and the
> string name, like
>
> %token <string> ID "identifier"
>
> Not to mention that I also want to provide support for
> internationalization. So what name should that be? ID?
> identifier? or identifiant in French?

In practice you just need the symbol name as is. Nobody needs the translation,
or if somebody really needs it, then anybody can achieve this very, very
easily on its own. That's trivial.

The main reason why people are asking for support on Bison side for the
features discussed here is that it is currently not trivial to achieve them
with own, custom code. You do need to have a profound knowledge of how the
internal skeleton algorithm works to be able to extra polate the missing
information by custom code on top of it.

Best regards,
Christian Schoenebeck
_______________________________________________
address@hidden https://lists.gnu.org/mailman/listinfo/help-bison


reply via email to

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