Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NULL token in JavaCC

I have strange problem with token < NULL: "null" > in my JavaCC parser. In expression like

String IsNullClause():
{
      String res = "";
}
{
     <IS> {res += " IS ";}
     [<NOT> {res += " NOT ";} ]
     <NULL> {res += " NULL ";}

{
    return res;
}
}

parser doesn't see NULL token and throws exception that "null" expected. If I change token definition to < NULL: "null_val" > or something else it works fine. Is this my mistake or JavaCC doesn't accept 'null' as a token value?

like image 692
3biga Avatar asked Sep 13 '26 03:09

3biga


1 Answers

There are sample Java language grammars in JavaCC package, with the following token difinition:

< NULL: "null" >

so I'm pretty sure JavaCC can handle null token.

Are you sure no token declared before NULL matches "null"? Tokens are matched in the order of declaration. You may try to declare NULL at the very beginning.

like image 73
asalamon74 Avatar answered Sep 15 '26 17:09

asalamon74



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!