The grammar documented here is all implemented, with more functionality coming in the next version. It's also of interest as an example grammar for those using Kern to build their own grammars, showcasing as much as possible an in-place one-to-one monad-to-macro mapping from parser combinator to generated code.
The non-ASCII Unicode operators and ideographs used in Grojure will always be single-grapheme. So whereas an ASCII operator could be 3 graphemes, e.g.
<=>, the Unicode operator will be only 1, e.g.
⇔. And whereas an ASCII name could be a camel-case word, e.g.
groupBy, the Unicode ideograph will be 1 character, e.g.
组, allowing future syntax using ideographs to not require spaces between them.
This release is 0.10.0. It depends on Clojure 1.5.1 and Kern 0.7.0.
Copyright © 2013 Gavin "Groovy" Grover
Distributed under the Eclipse Public License, the same as Clojure.
There's many ways to use Kern to run Grojure code.
One way is to put your code in a script file ending in
.grj, and call
grojure.grammar/run-grj-file on it:
(ns user (:use grojure.grammar)) (run-grj-file "my/dir/my_file.grj" "arg1" "arg2")
- first run the Clojure code in the
.cljfile with the same name, here "my/dir/my_file.clj"
- then run the Grojure code in the first paragraph of the
.grjfile, i.e. everything before the first U+2029 or end of file if none
The arguments are available as a list called
*args* in the
From within the first paragraph of the
.grj file, the contents of each subsequent paragraph can be run as Clojure code by calling the appropriate vector entry in either
_z, e.g. calling
_z(1)("th", 'r) with
(print (str (get *args* 0) (get *args* 1) "ee")) in the third paragraph of the file would print
Using the console
(ns user (:use grojure.grammar)) (run-console)
Enter your commands, followed by a blank line to run them:
let a=7 let b=8 prt a+b
To exit, enter
exit then the blank line:
The console mode is raw for now, but will be improved.
[GRAMMAR.MD] The grammar spec current for this version.
[ROADMAP.MD] A roadmap of future versions.
[CHANGES.MD] The list of changes made in each version so far.