In the directory $ISE_EIFFEL/examples/parse you will find a system that implements a processor for a grammar describing a simple language for expressin polynomials. A typical document in this language is the line
x;y: x * (y + 8 - (2 * x))
The beginning of the line, separated from the rest by a colon, is the list of variables used in the polynomial, separated by semicolons. The rest of the line is the expression defining the polynomial.The grammar can be described with the following grammar:
LINE = VARIABLES ":" SUM
VARIABLES = VAR .. ";"
SUM = DIFF .. "+"
DIFF = PRODUCT .. "-"
PRODUCT = TERM .. "*"
TERM = SIMPLE_VAR | INT_CONSTANT | NESTED
NESTED = "(" SUM ")" This grammar assumes a terminal
VAR, which must be defined as a token type in the lexical grammar. The other terminals are keywords, shown as strings appearing in the double quotes, for example "+".
When compiling the example, the executable process(.exe) is created. When executing the program, it will prompt for the name of a file with a polynomial description, reads a polynomial from the given file, prompts for integer values of the variables, and evaluates the polynomial.