ANTLR: Links - go-sqlparser/current GitHub Wiki
Learning ANTLR – a software modeling perspective
https://modeling-languages.com/learning-antlr-software-modeling/
by Jordi Cabot | Sep 20, 2018
I bet you all have heard about ANTLR (ANother Tool for Language Recognition) and have some idea of what it does (hint: it's a tool to generate parsers) but, if you're anything like me, you never cared about learning more about ANTLR as you ruled it out as irrelevant from a software modeling perspective.
Yes, textual modeling is important but we already have tools like Xtext for that, aren't we? Well, yes and no. My good friend Federico Tomassetti (we've had him here in this blog talking about creating DSLs on a budget with Kotlin , using ANTLR, no surprise here!) convinced me that I was too narrow-minded and keeping a very Eclipse-focused view of the problem.
There are several reasons you may prefer ANTLR over other more "modeling-oriented" solutions like Xtext to solve a language engineering problem:
- The ANTLR runtime is a small component, easy to integrate into online editors (anyone interested in building another web-based modeling editor?) or as the basis for building a full-blown compiler or model interpreter
- Xtext is based on Java, while you may need a parser that can be used in C#, Python or JavaScript. ANTLR has runtimes for all these languages.
- Xtext is based on OSGi. This has plenty of advantages in some cases but it also brings plenty of headaches and dependencies that make difficult to use Xtext parsers outside the Eclipse environment.
- And sometimes you just don't want to run your parser within any kind of Eclipse-based environment. If so, it's easier to directly use ANTLR.
- Or you may not even be interested in having any kind of IDE for your language, e.g. when transpiling your input language to another language. In those cases, all the powerful Xtext IDE features (like autocompletion) are irrelevant and therefore a simpler and lighter option as the one ANTLR provides is the way to go.
As usual, there is no one-size-fits-all tool but I'm now convinced that knowing ANTLR is a requirement for any language engineer, even if your goal is to develop domain-specific modeling languages. You never know when the flexibility of ANTLR will come in handy!.
You can learn ANTLR on your own. The official ANTLR website and its reference book include plenty of useful information. But, without a doubt, the best way to learn ANTLR on your own is to head on this ANTLR mega tutorial where you'll learn:
- the basics: what a parser is, what it can be used for
- see how to setup ANTLR to be used from Javascript, Python, Java and C#
- discuss how to test your parser
- present some advanced features
all with tons of examples
ANTLR Tutorial - Hello Word
http://meri-stuff.blogspot.com/2011/08/antlr-tutorial-hello-word.html
FRIDAY, AUGUST 26, 2011
Antlr stands for ANother Tool for Language Recognition.
This post begins with a small demonstration of ANTLR usefulness. Then, we explain what ANTLR is and how does it work. Finally, we show how to compile a simple 'Hello word!' language into an abstract syntax tree. The post explains also how to add error handling and how to test the language.
Next post shows how to create a real expression language.
.
.
.
ANTLR Tutorial: a Peek Into the Theory
https://dzone.com/articles/antlr-a-peek-into-the-theory
Demystify grammar with this down-to-earth analysis.
Vladimir Kozhaev · Sep. 16, 19
There seems to be a perennial confusion with teaching the theory behind programming in universities. The program of most universities implies teaching theory during the first two years when students actually can not code and do not understand how to employ the knowledge gained from the theory.
Courses often do not contain a sufficient number of hands-on examples and case studies. That’s why this knowledge is often treated as lifeless theory that students mindlessly memorize to pass exams only to forget it by the time they graduate. As a result, when a programmer actually faces theory in industry, they often do not even know how to apply it.
I’ll take another way: I’ll explain only the information relevant to work or necessary for a compelling explanation of a hands-on example. We will definitely return to more complex concepts later when you develop a sufficient understanding of why we need it at all.
.
.
.