[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to Filter or to skip garbage
a further question:
Very often I would like to work on very specific
parts of a text to scann/parse.
Everything else should be preserved.
Simple example, I want to find all function prototypes and all
heads of the function definitions.
The body of the functions and text between them and between
prototypes are not interesting but should be kept in the ast.
Very simple grammar:
prog ::= ( garbage | prototype | function)*;
function ::= head body;
prototype ::= head semi-colon;
How do I define garbage in thus that the scanner or the parser
can cunstruct a garbage token or a garbage rule?
A helping way would be this: I try to shift until a semicolon is
found(end of most usefull constructs in C/C++/JAVA), but if it is
not possible to reduce now, I would empty the parsestack and create
a list of the tokens and yield a garbage node for the AST (holding
this token list).
How would one achieve this?
Thanx a lot!