Finding direct left recursion in an Antlr grammar via XPath

“//parserRuleSpec[RULE_REF/text() = ruleBlock/ruleAltList/labeledAlt/alternative/[name()=’element’][1]/atom/ruleref/[1]/text()]”

This XPath expression is the first important rule I wrote for Antlr grammars, which finds all rules that have direct left recursion. Finding direct left recursion is an important step for removing indirect left recursion.

My efforts for getting XPath working with Antlr are starting to finally pay off.

–Ken

Posted in Tip

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.