ANTLR4 runtime library
To use this package, run the following command in your project's root directory:
Put the following dependency into your project's dependences section:
The Antlr4DTarget represents an full featured and tested port of ANTLR 4.
This covers the runtime library, the tool to translate the syntax into D code and the tests for the runtime library. See also ANTLR version 4.8.
Like other language ports, this D runtime library uses UTF-8.
- Download or clone the package
- Change directory to the root of the package and call dub.
- You will find the generated ATLR D runtime library in lib/libantlr-d.a
- The ANTLR tool for D will be generated by make build_examples (./build.ps1 build_examples on windows) in build/antlr4-4.8/tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar
- java 1.8
- 7-Zip (Only on windows)
grammar Expr; prog: (expr NEWLINE)* ; expr: expr ('*'|'/') expr | expr ('+'|'-') expr | INT | '(' expr ')' ; NEWLINE : [\r\n]+ ; INT : [0-9]+ ;
in the file Expr.g4.
java -jar -Dlanguage=D build/antlr4-4.7.2/tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar Expr.g4
and the correspondig Lexer, Parser and Listener D-Source files are generated. Use the the -visitor option in cli
java -jar -visitor -Dlanguage=D build/antlr4-4.7.2/tool/target/antlr4-4.8-2-SNAPSHOT-complete.jar Expr.g4
and additional ExprVisitor.d and ExprBaseVisitor.d sources are created.
Externsion versus other ANTLR runtime versions
The data type to store text is Variant. This is handy for the rewriting feature on an indent-based syntax like Python. In this case we need a structure representing the text as well as the number of indents.
- Registered by Eugene Wissner
- 1.8.2 released 3 years ago
- Copyright (c) 2012-2019 The ANTLR Project. All rights reserved.