github.com/antlr/antlr4/runtime/Go/antlr/v4 (go): Package antlr implements the Go version of the ANTLR 4 runtime.  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 parse trees and also generates a listener interface (or visitor) that makes it easy to respond to the recognition of phrases of interest.  ANTLR supports the generation of code in a number of target languages, and the generated code is supported by a runtime library, written specifically to support the generated code in the target language. This library is the runtime for the Go target.  To generate code for the go target, it is generally recommended to place the source grammar files in a package of their own, and use the `.sh` script method of generating code, using the go generate directive. In that same directory it is usual, though not required, to place the antlr tool that should be used to generate the code. That does mean that the antlr tool JAR file will be checked in to your source code control though, so you are free to use any other way of specifying the version of the ANTLR tool to use, such as aliasing in `.zshrc` or equivalent, or a profile in your IDE, or configuration in your CI system.  Here is a general template for an ANTLR based recognizer in Go:  Make sure that the package statement in your grammar file(s) reflects the go package they exist in. The generate.go file then looks like this:  And the generate.sh file will look similar to this:  depending on whether you want visitors or listeners or any other ANTLR options.  From the command line at the root of your package “myproject” you can then simply issue the command:  Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.  Use of this file is governed by the BSD 3-clause license, which can be found in the LICENSE.txt file in the project root.
Keywords: antlr|antlr4|cpp|csharp|dart|golang|grammar|java|javascript|language-recognition|parse|parser-generator|parsing|php|python|swift