Re: Renaming idea for a future version.

A “pragmatic” alternative:

So in the pragma proposal commits I just told you not to bother looking at, there’s an example of a pragma which can override the name of a nonterminal with the value of one of its terms…

In fact I think you need such a term in order to define pragmas, at least in the form that Michael and I are currently favouring.

It might look something like:

#name “month”
nmonth:  d, d.

or if you prefer not to make it global for nmonth,

iso: year, "-", #name “month” nmonth, "-", day.

The empty string has the special
meaning that the name should be taken as the value of the following terminal or non-terminal.

_________________
Tomos Hillman
eXpertML Ltd
+44 7793 242058
On 27 Oct 2021, 8:25 PM +0100, Steven Pemberton <steven.pemberton@cwi.nl>, wrote:
> Working further on my tutorial.
> I give examples of how to rename an element:
>
> start: -date.
>
> so a <start> element has the same content structure as a <date>.
>
> But it would be handy to go in the other direction too.
>
> date: day, " ", month, " ", year.
> day: d, d?.
> month: "January"; "February"; etc.
> year: d, d, d, d.
>
> iso: year, "-", nmonth, "-", day.
> nmonth: d, d.
>
> the month and nmonth elements have to have different names, because they
> have different syntaxes.
>
> Strawperson proposal:
>
> iso: year, "-", nmonth^month, "-", day.
>
> Read "an nmonth serialised as <month>", and by extension, used in a rule
> definition:
>
> nmonth^month: d, d.
>
> Steven
>

Received on Wednesday, 27 October 2021 19:37:08 UTC