项目作者: babeloff

项目描述 :
A boot-clj set of tasks for working with antlr4.
高级语言: Clojure
项目地址: git://github.com/babeloff/boot-antlr4.git
创建时间: 2017-10-03T20:36:50Z
项目社区:https://github.com/babeloff/boot-antlr4

开源协议:Eclipse Public License 1.0

下载


boot-antlr4

Build Status
Clojars Project

Boot tasks for working with antlr4.
This is alpha software; it is under ongoing development.
Backward compatibility is not guaranteed.

Usage

Anltr4 is a parser and lexer generator.

Run the antlr4 task:

  1. $ boot antlr4 -g AqlLexerRules.g4

Then require the task:

  1. (require '[babeloff.antlr4 :as antlr :refer [generate exercise]])

The generate task generates java classes from the antlr4 grammar files.
The exercise task provides some basic manipulations using the antlr4 TestRig.
For usage please study the
parser project
which demonstrates how to extend the Antlr4 grammar itself
to allow a literate programming style.

You can get started with live-coding with a build.boot like the following:

  1. (deftask build
  2. [s show bool "show the arguments"]
  3. (comp
  4. (watch) ;; [1]
  5. (generate :grammar "AqlLexerRules.g4") ;; [2]
  6. (generate :grammar "Aql.g4") ;; [3]
  7. (target :dir #{"target"}))) ;; [4]

The [1] enables the live-coding experience with the source files being watched.
The [2] lexer is constructed first and its output including the lexer tokens
are included in the fileset passed to the next phase.
The [3] generated files are placed in the target directory.

License

Copyright © 2017 Fredrick P. Eisele

Distributed under the Eclipse Public License either
version 1.0 or (at your option) any later version.

Notes

This approach is an alternative to other development
environments which use an interpreter.
The interpreter has some limitations as currently written.
In particular as the lexer makes use of constructs
which are not compatible with a combined grammar.