Defining Keywords - A lot of unused rule warnings

Hi, I’m working on a grammar where I have a lot of keywords.

and, for something like this,

Alpha Beta Gamma Delta;

Alpha, Beta, Gamma and, Delta are individual keywords and should be recognised as such.

The way I’m currently doing it is


Expr {

Alpha Beta Gamma Delta Semicolon

}


@external specialize {Identifier} specializeIdentifier from "./tokens" {
 
   Alpha, 
   Beta,
   Gamma,
   Delta

}

Am I doing it wrong? Is there a better approach for this? (and to lose the unused rule warnings?)

If they are used the warnings shouldn’t occur—that’d be a bug.

And if these all have the same syntactic role, it’d be less verbose to just define them under some single name (I don’t know what would be appropriate, but say you call them GreekLetterKeyword), and then have your external specializer hold a table that matches against all these keywords and emits a GreekLetterKeyword when appropriate.

1 Like