项目作者: babeloff

项目描述 :
A companion for boot-antlr4. It will demonstrate extending the ANTLR4 grammar with literate programming.
高级语言: ANTLR
项目地址: git://github.com/babeloff/boot-antlr4-parser.git
创建时间: 2017-10-20T14:00:19Z
项目社区:https://github.com/babeloff/boot-antlr4-parser

开源协议:Eclipse Public License 1.0

下载


demo project : literate antlr4

Build Status
Clojars Project

This demo does two things:

  1. Demonstrates how the provided tasks may be used to do live-coding
  2. Extend the Antlr4 grammar itself to allow a literate programming style.

Live-coding

This adds tasks for parsing Antlr4 grammars, not for generating code from them:

  1. (require
  2. '(boot [core :as boot :refer [deftask]]
  3. [util :as util]
  4. [task-helpers :as helper])
  5. '(babeloff
  6. [boot-antlr4 :as antlr]
  7. [boot-antlr4-parser :as coach])
  8. (deftask parse-grammar
  9. [s show bool "show the arguments"]
  10. (s/check-asserts true)
  11. (let [input-dir-str "./src/antlr4"
  12. input-dir (Paths/get input-dir-str no-path-extensions)
  13. input-raw-s
  14. (let [children (Files/walk input-dir 1 no-file-visit-options)]
  15. (iterator-seq (.iterator children)))
  16. gm (get-path-matcher "glob:\*.{g4}")
  17. input-file-s (filter #(matches gm %1) input-raw-s)]
  18. (comp
  19. (coach/exercise
  20. :start-rule "grammarSpec"
  21. :tree false
  22. :edn true
  23. :rdf :jena
  24. :postscript false
  25. :tokens false
  26. :input input-file-s))))

This sample shows the construction of a new task
using the exercise task provided by this project.

Literate Antlr4

This is a work in progress.
The goal is to extend the work on literate programming to
include multiple isomorphic representations.
In this way error messages will provide links into the
source code in a useful fashion.