Basic question about .grammar file

I’m trying to write a simple grammar that recognizes as entities Both Capitalized words and certain verbs.
My .grammar file is like this:
@tokens {
Identifier { $[A-Z][A-Za-z]+ }
Verb { “sumando” | “restando” | “multiplicando” }
space { $[ \t\n\r]+ }

@skip { space }

@top Entities { (Identifier | Verb)+ }

But after running ‘npm run prepare’ I get the following message:
[!] (plugin rollup-plugin-lezer) Error: Could not load /home/javier/Documents/bonalLezer/src/my.grammar: Unexpected token ‘+’ (/home/javier/Documents/bonalLezer/src/my.grammar 2:29)

Thanks in advance for your help.


You seem to be missing an $ in front of the second character set.

Also, matching keywords tokens like this is problematic, because it will also match them if there are additional letters after the keyword. You’ll probably want to have an additional token type (lowerCaseIdentifier or so) and use @specialize to, after such an identifier has been matched, mark it as a different token if it contains one of those words.

Thanks very much for your answer!