lezer-parser/lezer

Inline terms not exported

ashtonsix opened this issue · 2 comments

It is my expectation that this grammar:

@top Program { Term[@export] { "." } }

Would produce a terms file like this (or throw an error):

export const
  Program = 1,
  Term = 2

But it actually produces a terms file like this:

export const
  Program = 1

For comparison, here is a grammar that produces the expected terms file:

@top Program { Term }
Term[@export] { "." }

This is by design, because you can have multiple inline rules with the same name. Move them to the top level to export them.

Attached patch adds a warning when you do this.