]> gitweb.factorcode.org Git - factor.git/commitdiff
Add <EBNF ... ENBF> syntax to return a parser object
authorChris Double <chris@bethia.(none)>
Fri, 4 Jul 2008 00:40:42 +0000 (12:40 +1200)
committerChris Double <chris@bethia.(none)>
Thu, 10 Jul 2008 01:56:06 +0000 (13:56 +1200)
extra/peg/ebnf/ebnf.factor

index 2a6b55ad9da70ce9c1e13da8dc165274dd4f92ae..ff4bd2db61c94e7af58aaa6330ccf2f117d61f58 100644 (file)
@@ -518,11 +518,16 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
     "Could not parse EBNF" throw\r
   ] if ;\r
 \r
+: parse-ebnf ( string -- hashtable )\r
+  'ebnf' parse check-parse-result ast>> transform ;\r
+\r
 : ebnf>quot ( string -- hashtable quot )\r
-  'ebnf' parse check-parse-result \r
-  parse-result-ast transform dup dup parser [ main swap at compile ] with-variable\r
+  parse-ebnf dup dup parser [ main swap at compile ] with-variable\r
   [ compiled-parse ] curry [ with-scope ] curry ;\r
 \r
+: <EBNF "EBNF>" reset-tokenizer parse-multiline-string parse-ebnf main swap at  \r
+  parsed reset-tokenizer ; parsing\r
+\r
 : [EBNF "EBNF]" reset-tokenizer parse-multiline-string ebnf>quot nip \r
   parsed \ call parsed reset-tokenizer ; parsing\r
 \r