Handling multiple non-terminal without space

Sep 21, 2010 at 5:15 PM


I'm writing grammar for unit of measure.  The syntax is like:


PREFIX_SYMBOL : 'c' | 'm' | 'k';  // c-centi, m-milli, k-kilo

ATOM_UNIT : 'g' | 's'; // g - gram, s - second

How can I define this in Irony which might accomodate units like "cm" (c centimeter), "ms" (millisecond)?  Irony throws syntax error.



Sep 21, 2010 at 7:46 PM

In this case it might be simpler to define all combinations directly, there are just six.

Otherwise, to allow two symbols follow each other without space, you should set special Terminal flag on the "first" set of symbols, like AllowAlphaAfter, don't remember the exact name


Sep 22, 2010 at 4:03 AM

Thanks Rivan.  It is AllowAlphaAfterKeyword in KeyTerm.  Now, it is working.  The reason I'm selecting this option is the grammar has more combinations than the one shown above.