0

I would like to ask if the word "IS" is a reserved word. Here is why I am asking. The language that I am trying to create a parser for is a priority language. I have an assignment that looks like this:

%VARIABLE    IS STRING 

Using the Antlr interpreter, I type in the statement above and I get an error stating a 'MisMatchedSetException'.

If I type:

%VARIABLE    AND STRING

Everything works as expected.

I spent some time looking around for a solution, but nothing so far.

Here is a part of my grammar:

assignis :  '%' IDENT logical_operator types ;

types    : ('FIXED' | 'STRING' | 'FLOAT');

logical_operator : 'IS' | 'AND';

IDENT    : ('a'..'z' | 'A'..'Z' | '0'..'9' | DOT)+;
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
  • No, `"IS"` is no reserved word. The problem lies in your grammar but not in the part you posted. Can you post your entire grammar, or at least that much of it that produces the error/exception? – Bart Kiers Apr 13 '12 at 19:10
  • Even if `is` (or `IS`) was a reserved word, it wouldn't be a problem here because it appears in the grammar as a quoted literal. `class` is a reserved word in Java, but `"class"` is a perfectly acceptable String literal. – Sam Harwell Apr 13 '12 at 19:37
  • Now that you mention it. I went back and remove each rule one at a time and found that: IS: 'IS' and ISPRESENT : 'IS PRESENT' - conflict. So I rewrote it as ISPRESENT : IS 'PRESENT' and we are back in business. – Steve Nelson Apr 13 '12 at 20:19
  • @Steve, good to hear you resolved it. Feel free to remove the question in that case. – Bart Kiers Apr 13 '12 at 20:40

0 Answers0