antlr-d 1.8.0

ANTLR4 runtime library


To use this package, run the following command in your project's root directory:

Antlr4DTarget

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.7.3 yet.

This D port of ANTLR 4 uses UTF-8 characters as input stream.

Install

  1. Download or clone the package
  2. Change directory to the root of the package and call dub.
  3. You will find the generated ATLR D runtime library in lib/libantlr-d.a
  4. The ANTLR tool for D will generated be by make build_examples (./build.ps1 build_examples on windows) in build/antlr4-4.7.2/tool/target/antlr4-4.7.2-complete.jar

Dependencies

ANTLR tool
  • java 1.8
  • maven
  • 7-Zip (Only on windows)

Example

Put the

grammar Expr;
prog:	(expr NEWLINE)* ;
expr:	expr ('*'|'/') expr
    |	expr ('+'|'-') expr
    |	INT
    |	'(' expr ')'
    ;
NEWLINE : [\r\n]+ ;
INT : [0-9]+ ;

in the file Expr.g4.

Now call

java -jar -Dlanguage=D build/antlr4-4.7.2/tool/target/antlr4-4.7.2-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.7.2-complete.jar Expr.g4

and additional ExprVisitor.d and ExprBaseVisitor.d sources are created.

Externsion to 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.

Restrictions

  • not ported to the last version of antlr 4.8
Authors:
  • Egbert Voigt <Egbert.Voigt@funkwerk-itk.com>
Dependencies:
none
Versions:
1.8.1 2020-May-05
1.8.0 2020-Apr-24
1.7.4 2020-Apr-20
1.7.3 2020-Apr-15
1.7.2 2020-Apr-07
Show all 46 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 262 downloads total

Score:
1.8
Short URL:
antlr-d.dub.pm