Permalink
Browse files

Final work in Clojure.

  • Loading branch information...
richard-lyman committed Aug 19, 2013
1 parent 05f0698 commit ea0c45894024e6b5e5a39e1178bad1d213112e4d
Showing with 1,372 additions and 273 deletions.
  1. +9 −3 .gitignore
  2. +12 −12 README.markdown
  3. +13 −0 README.md
  4. BIN amotoen.zip
  5. +3 −0 doc/intro.md
  6. +806 −0 edn · richard-lyman amotoen Wiki.htm
  7. BIN edn · richard-lyman amotoen Wiki_files/b3bfe825a0937c775ba355650dc809a3
  8. +4 −0 edn · richard-lyman amotoen Wiki_files/frameworks-0f165a24ede5fce08cc34dbaba10d16d4ce5e4ac.js
  9. +60 −0 edn · richard-lyman amotoen Wiki_files/ga.js
  10. +1 −0 edn · richard-lyman amotoen Wiki_files/github-3d4ea5d8fbddac3c985f3d64312cd0c66fba92b6.css
  11. +7 −0 edn · richard-lyman amotoen Wiki_files/github-f6d238c9577ed5ec5aa0da824b890db7f46c0f73.js
  12. +1 −0 edn · richard-lyman amotoen Wiki_files/github2-3d4cecab661741b52969cd3455d315cb461c06ff.css
  13. BIN edn · richard-lyman amotoen Wiki_files/github_logo.png
  14. BIN edn · richard-lyman amotoen Wiki_files/logov7@4x-hover.png
  15. BIN edn · richard-lyman amotoen Wiki_files/logov7@4x.png
  16. BIN edn · richard-lyman amotoen Wiki_files/octocat.png
  17. +1 −0 edn · richard-lyman amotoen Wiki_files/track.js
  18. +2 −0 edn · richard-lyman amotoen Wiki_files/wiki-b1dac2fb8f79699637499184009b95a82d8282e9.js
  19. BIN edn_amotoen.zip
  20. +6 −10 project.clj
  21. +12 −12 res/README.markdown
  22. +6 −0 src/amotoen/core.clj
  23. +240 −146 src/com/lithinos/amotoen/core.clj
  24. +11 −11 src/com/lithinos/amotoen/grammars/json.clj
  25. +19 −19 src/com/lithinos/amotoen/grammars/minimark.clj
  26. +1 −1 test/JSONTests/1.out
  27. +1 −1 test/JSONTests/2.out
  28. +1 −1 test/JSONTests/3.out
  29. +1 −1 test/JSONTests/4.out
  30. +1 −1 test/JSONTests/5.out
  31. +68 −33 test/com/lithinos/amotoen/test/core.clj
  32. +16 −16 test/com/lithinos/amotoen/test/csv.clj
  33. +9 −6 test/com/lithinos/amotoen/test/json.clj
  34. +61 −0 test/com/lithinos/amotoen/test/parsely.clj
View
@@ -1,4 +1,10 @@
-lib
-.lein*
+/target
+/lib
+/classes
+/checkouts
pom.xml
-target
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
View
@@ -147,12 +147,12 @@ An example of this format using the CSV grammar and an input of just `a` is as f
```
If the more common output is not available, or you'd like to work with an AST, you can generate your own AST.
The following is only one of several different paths to producing an AST from a grammar and an input.
-One way is to call the Amotoen function 'pegasus' and provide three arguments.
-The first argument to pegasus is the key for the root rule in the grammar, the rule that should be run first.
+One way is to call the Amotoen function 'to-ast' and provide three arguments.
+The first argument to to-ast is the key for the root rule in the grammar, the rule that should be run first.
The second argument is the grammar definition.
The third argument is something that fulfils the IAmotoen protocol, and the provided 'wrap-string' function will do just that for Strings.
Putting all these pieces together with the input from above of `a` you get:
- ```(pegasus :Document grammar (wrap-string "a"))```
+ ```(to-ast :Document grammar (wrap-string "a"))```
Much more information can be found in the tests for CSV, the com.lithinos.amotoen.test.csv package.
@@ -218,10 +218,10 @@ The grammar for Amotoen grammars is:
:Function [\( \f :_ :CljReaderFn :_ :Body :_* \)]
:CljReaderFn [\# \< '(% \>) '(* (% \>)) \>]
:Whitespace '(| \space \newline \return \tab \,)
- :Char [\\ (list '| (pegs "tab") (pegs "space") (pegs "newline") (pegs "return") '(% \space))]
+ :Char [\\ (list '| "tab" "space" "newline" "return" '(% \space))]
:AmotoenSymbol [:NonNumericCharacter '(* :AlphanumericCharactersPlus)]
- :NonNumericCharacter (list '% (lpegs '| "0123456789"))
- :AlphanumericCharactersPlus (lpegs '| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:/*+!-_?.")
+ :NonNumericCharacter (list '% (ls '| "0123456789"))
+ :AlphanumericCharactersPlus (ls '| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:/*+!-_?.")
}
```
<h2>Recent Improvements</h2>
@@ -234,35 +234,35 @@ As an example:
- Some function named 'custom-collapse' set to
```#(apply str %)```
- Some grammar 'g' set to
- ```{:S [(list 'f custom-collapse (pegs "abcabc"))]}```
+ ```{:S [(list 'f custom-collapse "abcabc")]}```
- Some input 'i' set to
```"abcabc"```
- An invocation like...
- ```(pegasus :S g (gen-ps i))```
+ ```(to-ast :S g (gen-ps i))```
- ... should return...
```{:S ["abcabc"]}```
Without supplying a custom collapse function:
- Some grammar 'g' set to
- ```{:S (pegs "abcabc")}```
+ ```{:S "abcabc"}```
- Other things alike, the result should be
```{:S [\a \b \c \a \b \c]}```
Another example:
- Some function named 'custom-collapse' set to
```#(apply str %)```
- Some grammar 'g' set to
- ```{:S [(list 'f custom-collapse '(* (lpegs '| "abc")))]}```
+ ```{:S [(list 'f custom-collapse '(* (ls '| "abc")))]}```
- Some input 'i' set to
```"aabbcc"```
- An invocation like...
- ```(pegasus :S g (gen-ps i))```
+ ```(to-ast :S g (gen-ps i))```
- ... should return...
```{:S ["aabbcc"]}```
Without supplying a custom collapse function:
- Some grammar 'g' set to
- ```{:S [(list '* (lpegs '| "abc"))]}```
+ ```{:S [(list '* (ls '| "abc"))]}```
- Other things alike, the result should be
```{:S [(\a \a \b \b \c \c)]}```
View
@@ -0,0 +1,13 @@
+# amotoen
+
+A Clojure library designed to ... well, that part is up to you.
+
+## Usage
+
+FIXME
+
+## License
+
+Copyright © 2012 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
View
Binary file not shown.
View
@@ -0,0 +1,3 @@
+# Introduction to amotoen
+
+TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
View
Binary file not shown.
View
@@ -1,10 +1,6 @@
-(defproject com.lithinos/amotoen "0.3.0-SNAPSHOT"
- :description "Amotoen is a Clojure library that supports PEG style definitions of grammars that can produce parsers."
- :url "http://www.lithinos.com/amotoen"
- :license {:name "EPL-v1.0" :distribution :repo :comments "same as Clojure" :url "http://www.eclipse.org/legal/epl-v10.html"}
- :source-path "src"
- :resource-paths ["res"]
- :dependencies [[org.clojure/clojure "1.4.0"]]
- :jar-name "amotoen.jar"
- :jar-exclusions [#"(markdown|project).clj" #"maven"]
- :manifest {"Built-By" "\"Richard Lyman\" <richard.lyman@gmail.com>"})
+(defproject amotoen "0.1.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :url "http://example.com/FIXME"
+ :license {:name "Eclipse Public License"
+ :url "http://www.eclipse.org/legal/epl-v10.html"}
+ :dependencies [[org.clojure/clojure "1.4.0"]])
View
@@ -147,12 +147,12 @@ An example of this format using the CSV grammar and an input of just `a` is as f
```
If the more common output is not available, or you'd like to work with an AST, you can generate your own AST.
The following is only one of several different paths to producing an AST from a grammar and an input.
-One way is to call the Amotoen function 'pegasus' and provide three arguments.
-The first argument to pegasus is the key for the root rule in the grammar, the rule that should be run first.
+One way is to call the Amotoen function 'to-ast' and provide three arguments.
+The first argument to to-ast is the key for the root rule in the grammar, the rule that should be run first.
The second argument is the grammar definition.
The third argument is something that fulfils the IAmotoen protocol, and the provided 'wrap-string' function will do just that for Strings.
Putting all these pieces together with the input from above of `a` you get:
- ```(pegasus :Document grammar (wrap-string "a"))```
+ ```(to-ast :Document grammar (wrap-string "a"))```
Much more information can be found in the tests for CSV, the com.lithinos.amotoen.test.csv package.
@@ -218,10 +218,10 @@ The grammar for Amotoen grammars is:
:Function [\( \f :_ :CljReaderFn :_ :Body :_* \)]
:CljReaderFn [\# \< '(% \>) '(* (% \>)) \>]
:Whitespace '(| \space \newline \return \tab \,)
- :Char [\\ (list '| (pegs "tab") (pegs "space") (pegs "newline") (pegs "return") '(% \space))]
+ :Char [\\ (list '| "tab" "space" "newline" "return" '(% \space))]
:AmotoenSymbol [:NonNumericCharacter '(* :AlphanumericCharactersPlus)]
- :NonNumericCharacter (list '% (lpegs '| "0123456789"))
- :AlphanumericCharactersPlus (lpegs '| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:/*+!-_?.")
+ :NonNumericCharacter (list '% (ls '| "0123456789"))
+ :AlphanumericCharactersPlus (ls '| "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:/*+!-_?.")
}
```
<h2>Recent Improvements</h2>
@@ -234,35 +234,35 @@ As an example:
- Some function named 'custom-collapse' set to
```#(apply str %)```
- Some grammar 'g' set to
- ```{:S [(list 'f custom-collapse (pegs "abcabc"))]}```
+ ```{:S [(list 'f custom-collapse "abcabc")]}```
- Some input 'i' set to
```"abcabc"```
- An invocation like...
- ```(pegasus :S g (gen-ps i))```
+ ```(to-ast :S g (gen-ps i))```
- ... should return...
```{:S ["abcabc"]}```
Without supplying a custom collapse function:
- Some grammar 'g' set to
- ```{:S (pegs "abcabc")}```
+ ```{:S "abcabc"}```
- Other things alike, the result should be
```{:S [\a \b \c \a \b \c]}```
Another example:
- Some function named 'custom-collapse' set to
```#(apply str %)```
- Some grammar 'g' set to
- ```{:S [(list 'f custom-collapse '(* (lpegs '| "abc")))]}```
+ ```{:S [(list 'f custom-collapse '(* (ls '| "abc")))]}```
- Some input 'i' set to
```"aabbcc"```
- An invocation like...
- ```(pegasus :S g (gen-ps i))```
+ ```(to-ast :S g (gen-ps i))```
- ... should return...
```{:S ["aabbcc"]}```
Without supplying a custom collapse function:
- Some grammar 'g' set to
- ```{:S [(list '* (lpegs '| "abc"))]}```
+ ```{:S [(list '* (ls '| "abc"))]}```
- Other things alike, the result should be
```{:S [(\a \a \b \b \c \c)]}```
View
@@ -0,0 +1,6 @@
+(ns amotoen.core)
+
+(defn -main
+ "I don't do a whole lot."
+ [& args]
+ (println "Hello, World!"))
Oops, something went wrong.

0 comments on commit ea0c458

Please sign in to comment.