ANTLR Mega Tutorial
I last played around with ANTLR in 2012 (when it was version 3) and I discovered that there&#x27;s a &quot;bigger picture&quot; to the parser generator universe that most tutorials don&#x27;t talk about:<p>1) ANTLR is a good tool for generating &quot;happy path&quot; parsers.  With a grammar specification, it easily generates a parser that accepts or rejects a piece of source code.  However, it&#x27;s not easy to use the hooks to generate high quality diagnostic error messages.<p>2) ANTLR was not good for speculative parsing or probabilistic parsing which would be the basis of today&#x27;s generation of tools such as &quot;Intellisense&quot; not giving up on parsing when there&#x27;s an unclosed brace or missing variable declaration.<p>The common theme to the 2 bullet points above is that a high quality compiler written by hand will hold multiple &quot;states&quot; of information and an ANTLR grammar file doesn&#x27;t really have an obvious way to express that knowledge.  A pathological example would be the numerous &quot;broken HTML&quot; pages being successfully parsed by browsers.  It would be very hard to replicate how Chrome&#x2F;Firefox&#x2F;Safari&#x2F;IE doesn&#x27;t choke on broken HTML by using ANTLR to generate an HTML parser.<p>In short, ANTLR is great for <i>prototyping</i> a parser but any industrial-grade parser released into the wild with programmers&#x27; expectations of helpful error messages would require a hand-written parser.<p>Lastly, the lexing (creating the tokens) and parsing (creating the AST) is a <i>very tiny percentage</i> of the total development of a quality compiler.  Therefore, ANTLR doesn&#x27;t save as much time as one might think.<p>I welcome any comments about v4 that makes those findings obsolete.