Move towards having ebnf infer
parent
5f37b4fc72
commit
0db0d9cd44
|
@ -282,7 +282,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
|
|||
|
||||
: ebnf>quot ( string -- hashtable quot )
|
||||
'ebnf' parse check-parse-result
|
||||
parse-result-ast transform dup main swap at compile [ parse ] curry ;
|
||||
parse-result-ast transform dup main swap at compile [ compiled-parse ] curry ;
|
||||
|
||||
: [EBNF "EBNF]" parse-multiline-string ebnf>quot nip parsed ; parsing
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ C: <head> peg-head
|
|||
f lrstack set
|
||||
H{ } clone heads set
|
||||
H{ } clone packrat set
|
||||
] H{ } make-assoc swap bind ;
|
||||
] H{ } make-assoc swap bind ; inline
|
||||
|
||||
|
||||
: compiled-parsers ( -- cache )
|
||||
|
@ -236,9 +236,11 @@ GENERIC: (compile) ( parser -- quot )
|
|||
: compile ( parser -- word )
|
||||
[ compiled-parser ] with-compilation-unit ;
|
||||
|
||||
: compiled-parse ( state word -- result )
|
||||
swap [ execute ] with-packrat ; inline
|
||||
|
||||
: parse ( state parser -- result )
|
||||
dup word? [ compile ] unless
|
||||
[ execute ] curry with-packrat ;
|
||||
dup word? [ compile ] unless compiled-parse ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
|
|
Loading…
Reference in New Issue