1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
This example shows the use of the standard location stack as well as passing
d_val to the scanner.
The use of the standard location stack is indicated so by the %lsp-needed
directive. In this case, the %scanner directive can be used too, but the
parser probably needs a constructor passing d_loc and d_val to the scanner. In
the example this is accomplished using the following in-line Parser
constructor:
Parser()
:
d_scanner(&d_loc, &d_val)
{}
The grammar itself is trivial. It only accepts empty lines or lines containing
one integral numerical value. Any other input results in an error (which is
handled).
To terminate the program, ^C must be used.
|