samedi 27 juin 2015

JavaCC - Match some words except some others

I am trying to create a parser for first-order logic using the javacc and I have the following problem.

I have this:

< VARIABLE : < LOWER > (< INNER >)* >

where

< #INNER :
( < UPPER >
| < LOWER >
| < DIGIT >
| < UNDERSCORE > ) >

< #DIGIT : [ "0"-"9" ] >
< #LOWER : [ "a"-"z" ] >
< #UPPER : [ "A"-"Z" ] >
< #UNDERSCORE: "_" >

, but I want to exclude some words from this. In particular i want to exclude the words sum, count, avg, max and min. Is there a way to to this? In other words, I want the variables to begin with a lowercase letter followed by any number of inner tokens, where the inner token may be an uppercase letter, a lowercase letter, a digit or an underscore. However, i do not want the variables to take values such as sum, count, avg, max and min.

Aucun commentaire:

Enregistrer un commentaire