The problem with multiple assignments is quite easy to process in grammar. Just allow multiple assignments:
assign_stmt = 'assign' assignments '.' ; assignements = ; assignments = assignments target '=' expression ;
One way you can use is to increase the grammar to allow preprocessor token sequences wherever a nonterminal can be resolved, and simply not perform preprocessor expansion. For your example, you have a grammar rule:
expression = ... ;
just add a rule:
expression = '{' include_reference '}' ;
This works to the extent that the preprocessor is not offensively used to create multiple lanaguage elements that span nonterminal boundaries.
What anlaysis code do you intend to do? To a large extent, in order to do something, you will need to name and print the resolution, which will require an extension of the preprocessor directives. In this case, you will need a more complex scheme, because you need an extended tree for name resolution, as well as the need to include related information to the side.
Our DMS Software Reengineering Toolkit has an OpenEdge parser, in which we present the trick of the previous "save file links" links. The DMS C parser adds a “macro node” to the tree, where the macro (OpenEdge) includes “just a fun way to write a macro definition”), the child nodes contain the tree, as you expect, and the reference information that accesses the macro definition. This requires some careful organization and a large number of special layouts of the nodes where they occur.
source share