Trash, the toolkit for ANTLR grammars, is seeing a new life, all due to this old dog switching to new ways of programming: generative AI. At first, I hesitated to use the technology because I saw a lot of problems. But with the latest tools, I am convinced: gen-AI is a game changer.

Last year, I started using Anthropic’s Claude Code (v 4.x). I first had it analyze grammar ambiguities using the Trash toolkit, e.g., dotnet trparse --ambig in1.txt in2.txt in3.txt ... | trtree -a. Then, I had it write an XQuery4 engine, because I’ve been wanting to replace the XPath2 Xalan/Pychopath engine for years, but haven’t found a good replacement. (The SaxonCS software requires a license.) In February, I was using Claude to make large changes to the PLDB, because I couldn’t understand the code, and needed a quick way to get up to speed.

Over the next few months, I had Claude Code work directly on Trash to solve bugs and add features. At first, the changes were small. But as I worked with Claude Code, pairing changes with testing, I felt more confident that gen-AI was for real.

A few months ago, I saw Konstantin Vyatkin using gen-AI to write a complete replacement for Antlr4 in Rust–which included a complete replacement of the ANTLR4 tool! At this point, I decided to use Claude Code to make large-scale changes to Trash. The first was to refactor the separately published apps as sub-applications to trash, version 1.x. For 2.x, I added the new XQuery4 engine; started rolling over the tools to use the new engine; added trinterp, a tool to output a grammar description for interpretation; and added interpretive parsing to trparse that implements Earley and ALL(*). As I was not happy with the speed and correctness of Claude Code finding and fixing problems with the new ALL(*) interpreter, I switched to OpenAI’s CodeX (v 5.x), and noticed a vast improvement in speed and quality of the fixes. For 3.x, I added a PAX/tar artifact pipeline between the toolkit apps, and improved the quality and speed of the interpretive parser. Most parsing runs only slightly slower than a native ANTLR4 parser in C#.

At this point, I do almost all development via generative AI. And, with it the question: Why use ANTLR4 anymore? There will be many more changes to come.