Hi Dave,
The SableCC philosophy for providing a
clean include
statement is for the
included file content not to be part
of the
syntax of the
including file. For example:
...
i = x + y;
include("file.xyz"); # includes additional computation
print(z);
...
In other words, the grammar would have an include statement among
its statements:
...
statement =
{assign} id assign exp sc |
{include} include l_par string r_par sc |
...
This way, you parse the including file as usual. Later, while
walking the AST, when you discover an include statement, you open
the included file and parse it using a new parser.
If, on the other hand, you are looking for
dirty C-like
preprocessing file inclusion, you'll have to do it the dirty C
way: implement a preprocessor to preprocess the character stream
before feeding it to the parser and deal with the complex issue of
figuring out how to provide syntax errors
locations to
your users.