GithubHelp home page GithubHelp logo

isabella232 / lein-antlr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pubnub/lein-antlr

0.0 0.0 0.0 112 KB

Plugin to allow processing of ANTLR grammars using the Leiningen build system for Clojure.

GAP 22.57% ANTLR 7.94% Clojure 69.49%

lein-antlr's Introduction

lein-antlr

lein-antlr is a Leiningen 2 plugin for generating source code from one or more ANTLR 4 grammars in a Leiningen project. It has roughly the same functionality as the Maven ANTLR plugin, and is intended to allow developers to integrate ANTLR-generated source code into a Clojure project without resorting to Maven or some other manual process.

To use lein-antlr in your project, simply add it to :plugins in your project.clj:

:plugins [[lein-antlr "0.3.0"]]

Version Compatibility

The ANTLR and Leiningen version supported by this plugin are as follows:

  • lein-antlr 0.3: ANTLR4 and Leiningen 2
  • lein-antlr 0.2: ANTLR3 and Leiningen 2
  • lein-antlr 0.1: ANTLR3 and Leiningen 1

Note that source code generated by ANTLR4 is not backwards-compatible with the ANTLR3 runtime. If you upgrade your project to use the 0.3 version of the lein-antlr plugin, you will also need to upgrade your project's ANTLR runtime dependency from version 3 to version 4. See the ANTLR4 migration guide for more details.

Usage

The lein-antlr plugin can be called from the command-line as follows:

% lein antlr

The plugin is configured in your project.clj as follows:

(defproject my-project
  ...
  :antlr-src-dir "src/antlr"
  :antlr-dest-dir "gen-src"
  :antlr-options {:Werror true
                  ... }
)

The plugin will scan the source directory specified by :antlr-src-dir and its subdirectories for all ANTLR grammar files (i.e. those files whose names end in '.g' or '.g4') and compile them, placing the generated source code into the destination directory specified by :antlr-dest-dir. Grammar files located in subdirectories of the source directory will have their generated code placed into corresponding subdirectories in the destination directory.

The default values for :antlr-src-dir and :antlr-dest-dir are 'src/antlr' and 'gen-src' respectively.

Options

The behavior of the ANTLR tool is configured using the :antlr-options entry in your project description. This entry should be a map of keyword-value pairs as follows:

Option Type Default Value Description
:atn boolean false generate rule augmented transition network diagrams
:encoding String specify grammar file encoding; e.g., euc-jp
:message-format String specify output style for messages in antlr, gnu, vs2005
:long-messages boolean false show exception details when available for errors and warnings
:listener boolean true generate parse tree listener (default)
:no-listener boolean false don't generate parse tree listener
:visitor boolean false generate parse tree visitor
:no-visitor boolean true don't generate parse tree visitor (default)
:package String as specified in grammar-files specify a package/namespace for the generated code
:depend boolean false generate file dependencies
:Werror boolean false treat warnings as errors
:Xlog boolean false dump lots of logging info to antlr-timestamp.log

Cleaning Up

The plugin can be configured to clean the generated source directory as part of the Leiningen 'clean' task, but this must be manually set up by adding the leiningen.antlr namespace to the project hooks, like so:

(defproject my-project
  ...
  :hooks [leiningen.antlr]
  ...
)

License & Copyright

Copyright (c) 2010 Revelytix, Inc.

The lein-antlr project is distrubuted under the Apache Software License, Version 2.0

lein-antlr's People

Contributors

rferraz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.