Compile ebnf->factor
parent
ed359b6623
commit
38806885e6
|
@ -1,6 +1,6 @@
|
||||||
! Copyright (C) 2007 Chris Double.
|
! Copyright (C) 2007 Chris Double.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel arrays strings math.parser sequences namespaces peg ;
|
USING: kernel parser words arrays strings math.parser sequences namespaces peg ;
|
||||||
IN: peg.ebnf
|
IN: peg.ebnf
|
||||||
|
|
||||||
TUPLE: ebnf-non-terminal symbol ;
|
TUPLE: ebnf-non-terminal symbol ;
|
||||||
|
@ -22,6 +22,11 @@ M: ebnf-terminal ebnf-compile ( ast -- quot )
|
||||||
ebnf-terminal-symbol , \ token ,
|
ebnf-terminal-symbol , \ token ,
|
||||||
] [ ] make ;
|
] [ ] make ;
|
||||||
|
|
||||||
|
M: ebnf-non-terminal ebnf-compile ( ast -- quot )
|
||||||
|
[
|
||||||
|
ebnf-non-terminal-symbol in get lookup ,
|
||||||
|
] [ ] make ;
|
||||||
|
|
||||||
M: ebnf-choice ebnf-compile ( ast -- quot )
|
M: ebnf-choice ebnf-compile ( ast -- quot )
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
@ -42,6 +47,12 @@ M: ebnf-sequence ebnf-compile ( ast -- quot )
|
||||||
[ call ] , \ map , \ seq ,
|
[ call ] , \ map , \ seq ,
|
||||||
] [ ] make ;
|
] [ ] make ;
|
||||||
|
|
||||||
|
M: ebnf-rule ebnf-compile ( ast -- quot )
|
||||||
|
[
|
||||||
|
dup ebnf-rule-symbol , \ in , \ get , \ create ,
|
||||||
|
ebnf-rule-elements ebnf-compile , \ define-compound ,
|
||||||
|
] [ ] make ;
|
||||||
|
|
||||||
DEFER: 'rhs'
|
DEFER: 'rhs'
|
||||||
|
|
||||||
: 'non-terminal' ( -- parser )
|
: 'non-terminal' ( -- parser )
|
||||||
|
|
Loading…
Reference in New Issue