4

I wish to make part of my JavaCC definitions case insensitive, but not globally.

TOKEN [IGNORE_CASE]:
{
  < STRA : "a" >
}
TOKEN :
{
  < STRB : "b" >
}

Above seems to make all tokens (STRA AND STRB) case insensitive. How to make only STRB case ignored?

Also, can I make following production case insensitive, for example, only "b = <...>" so?

private void expr() : 
{
  Token a, b;
}
{
  a = < STRA > | b = < STRB>
}

I admit I can't figure out this by reading the manual. Please help me out. Let me know if I didn't explain clearly. Thank you.

X.M.
  • 941
  • 3
  • 14
  • 22

1 Answers1

2

Make a separate list of tokens, Case sensitive and ignore case tokens then u need not declare statement globally as Ignore case = true. try code as below,

TOKEN [IGNORE_CASE]: {
 < STRB : "b" >
}

TOKEN : {
  < STRA : "a" >
}