hi! On Jan 31, 2010, at 11:15 PM, Terence Parr wrote:
Howdy. I'm toying with how to specify semantic checks for antlr v4. I can list a bunch of tree patterns and then test stuff like this:[...]
yeah, fugly.
I wonder if I can do something more readable. Perhaps these rules trigger methods in my SemanticsPipeline class. Like unit tests, I could make them all start with "rule" or "check" or "enforce" like:checkInvalidRule(int gtype, Token ruleID) { ...stuff in grammar action at moment... }checkInvalidRuleRef(int gtype, Token ruleID) {...}It would be easy to see the list of semantic rules ANTLR follows. it also separates the rules from the tree structure.
i always try to push as much code into separate classes as possible, if only for the reason that having it in actions makes it really hard to use an IDE. plus it makes the grammar itself much more readable, especially if the helper method names are appropriately named.
Other option is to put error conditions in grammar with predicates and repeat syntactic tree pattern.
"repeat" somehow raises a red flag on this side of the pond ;) cheers, -k -- Kay Röpke
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ antlr-dev mailing list [email protected] http://www.antlr.org/mailman/listinfo/antlr-dev
