From 228430512c0ed31a055d25326bb021cc6ad7c441 Mon Sep 17 00:00:00 2001
From: James Cash <james.nvc@gmail.com>
Date: Sat, 26 Apr 2008 15:55:39 -0400
Subject: [PATCH] Splitting EBNF parser to seperate vocab

---
 extra/lisp/parser/parser.factor | 36 +++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 extra/lisp/parser/parser.factor

diff --git a/extra/lisp/parser/parser.factor b/extra/lisp/parser/parser.factor
new file mode 100644
index 0000000000..0fac78ae75
--- /dev/null
+++ b/extra/lisp/parser/parser.factor
@@ -0,0 +1,36 @@
+USING: kernel peg.ebnf peg.expr math.parser sequences arrays strings
+combinators.lib ;
+
+IN: lisp.parser
+
+TUPLE: lisp-symbol name ;
+C: <lisp-symbol> lisp-symbol
+
+TUPLE: s-exp body ;
+C: <s-exp> s-exp
+
+EBNF: lisp-expr
+_            = (" " | "\t" | "\n")*
+LPAREN       = "("
+RPAREN       = ")"
+dquote       = '"'
+squote       = "'"
+digit        = [0-9]
+integer      = (digit)+                               => [[ string>number ]]
+float        = (digit)+ "." (digit)*                  => [[ first3 >string [ >string ] dipd 3append string>number ]]
+number       = float
+              | integer
+id-specials  = "!" | "$" | "%" | "&" | "*" | "/" | ":" | "<"
+              | " =" | ">" | "?" | "^" | "_" | "~" | "+" | "-" | "." | "@"
+letters      = [a-zA-Z]                               => [[ 1array >string ]]
+initials     = letters | id-specials
+numbers      = [0-9]                                  => [[ 1array >string ]]
+subsequents  = initials | numbers
+identifier   = initials (subsequents)*                => [[ first2 concat append <lisp-symbol> ]]
+string       = dquote ("\" . | !(dquote) . )*  dquote => [[ second >string ]]
+atom         = number
+              | identifier
+              | string
+list-item    = _ (atom|s-expression) _                        => [[ second ]]
+s-expression = LPAREN (list-item)* RPAREN             => [[ second <s-exp> ]]
+;EBNF