lezer-parser / lezer

Dev utils and issues for the Lezer core packages
33 stars 1 forks source link

Inline terms not exported #16

Closed ashtonsix closed 2 years ago

ashtonsix commented 2 years ago

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] { "." }
marijnh commented 2 years ago

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

marijnh commented 2 years ago

Attached patch adds a warning when you do this.