This project has moved and is read-only. For the latest updates, please go here.

how to check if variable names are the same

Aug 25, 2014 at 5:18 PM

i have a simple grammar like this:
Constant bla;  
where "Constant" is a keyword and "bla" some name, that the user can change.
i definded the grammar like this:
IdentifierTerminal identifier = new IdentifierTerminal("Identifier");
Defline.Rule = (ToTerm("Constant") + identifier + ";")

LVS.Rule = identifier + ToTerm("=") + number + ";";
now i want to check if the identifieres used in the second line (and in the LVS Rule) are one of the names from the "Constant" lines. how do i check that?
Aug 25, 2014 at 9:55 PM
Just run through generated parse tree, after parsing, using tree iterator/visitor. This is semantic analysis, not grammar/syntax thing, so it's done after parsing (normally)