Jepessen
Jepessen

Reputation: 12415

Declare a case insensitive keyword with EBNF

I want to declare with EBNF notation a keyword, i.e. switch.

<keyword_switch> ::= "switch";

Is there a way to declare the keyword as case insensitive without declare all possible letters combination?

I think that the following declaration is correct (but unsire, I'm a newbie with EBNF):

<keyword_switch> ::= ("S"|"s")("W"|"w")("I"|"i")("T"|"t")("C"|"c")("H"|"h");

but it's not very readable. Is there another simpler way?

Upvotes: 1

Views: 428

Answers (1)

rns
rns

Reputation: 761

<keyword_switch> ::= ("S"|"s")("W"|"w")("I"|"i")("T"|"t")("C"|"c")("H"|"h");

seems to be ok with antlr -- http://www.antlr3.org/pipermail/antlr-interest/2007-August/023267.html

Heretic as it may seem, I'd suggest

<keyword_switch> ::= "switch" | "Switch" | "SWITCH";

assuming that sWitch and sWiTcH etc. are hardly what a user would need.

Upvotes: 1

Related Questions