Sunday, April 23, 2023

book: Language Implementation Patterns

Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages by Terence Parr

Learn to build configuration file readers, data readers, model-driven code generators, source-to-source translators, source analyzers, and interpreters. You don’t need a background in computer science—ANTLR creator Terence Parr demystifies language implementation by breaking it down into the most common design patterns. Pattern by pattern, you’ll learn the key skills you need to implement your own computer languages.


Language Implementation Patterns



Testing ANTLR4

ANTLR.org

ANTLR (ANother Tool for Language Recognition) is a powerful parser generator for reading, processing, executing, or translating structured text or binary files. It's widely used to build languages, tools, and frameworks. From a grammar, ANTLR generates a parser that can build and walk parse trees.

ANTLR Lab: learn, test, and experiment with ANTLR grammars online!

antlr/antlr4-lab: A client/server for trying out and learning about ANTLR


Download ANTLR

The latest version of ANTLR is 4.12.0, released February 19, 2023


download and use Java from Oracle, not from java.com


copy .jar to Java "lib" folder, and
add location of antlr jar file to java CLASSPATH env var

C:\Program Files\Java\jdk-20\lib\antlr-4.12.0-complete.jar;%CLASSPATH%;

antlr4/javascript-target.md at master · antlr/antlr4 · GitHub

for JavaScript examples to work, the version of antrl4 jar file and antlr4.js have to match.

to achieve this one way is to set fixed version of antlr4.js in node.js package.json file


ANTLR examples from Strumenta

The ANTLR Mega Tutorial

gabriele-tomassetti/antlr-mega-tutorial: This is the companion repository of the ANTLR Mega Tutorial, that will explain everything you need to know to use ANTLR.


ANTLR and the web: a simple example - Strumenta

ftomassetti/antlr-web-example


VS Code plugins

ANTLR4 grammar syntax support - Visual Studio Marketplace