I’ve pulled all the Antlr parse tree editing routines into its own library yesterday. This library fills a gap between what is offered in the Antlr runtime (a psuedo XPath library, AddChild and Parent accessors for ParserRuleContext), and a full-blown transformation system like ASF+SDF. This library contains: a beefed-up XPath version 2 library; a tree …
Monthly Archives: July 2020
A command-line approach to transforms of Antlr grammars
This is just a note to myself regarding some ideas on a command-line tool for Antlr grammars. It should be clear to anyone: grammars, especially Antlr grammars, are first-class objects that can be manipulated and changed to improve readability or performance. Antlrvsix now incorporates almost two dozen transformations, ranging from unfold, fold, sort rules, remove …
Continue reading “A command-line approach to transforms of Antlr grammars”
Adding text editor highlighting rules in a dynamic manner
This is a note of an idea I posted in two Twitter threads (here, here, and here). I think it’s important to capture the idea before it gets lost when blogs and Twitter disappear. The problem with “semantic highlighting”, or what I would just call syntactic highlighting because there are really many levels of highlighting …
Continue reading “Adding text editor highlighting rules in a dynamic manner”
Tree transformations via XPath and S-expressions
I’ve finally have the right tools to now implement transforms over an Antlr parse tree. The first part of a transform is identifying what nodes in the tree that are going to be replaced. It turns out that the best tool to do that is an XPath engine, which I’ve rewritten in C# from Java …
Continue reading “Tree transformations via XPath and S-expressions”
Converting Bison precedence and associativity rules to Antlr
As noted in the Bison guide: The associativity of an operator op determines how repeated uses of the operator nest: whether â€x op y op z’ is parsed by grouping x with y first or by grouping y with z first. %left specifies left-associativity (grouping x with y first) and %right specifies right-associativity (grouping y with z first). %nonassoc specifies no associativity, which means that â€x op y op z’ is considered a syntax error.%precedence gives only precedence to the symbols, and defines no associativity at all. Use this …
Continue reading “Converting Bison precedence and associativity rules to Antlr”