peg fixes
parent
d92c19f694
commit
ec896eeba8
|
@ -20,7 +20,7 @@ M: just-parser (compile) ( parser -- quot )
|
|||
just-parser-p1 compiled-parser just-pattern curry ;
|
||||
|
||||
: just ( parser -- parser )
|
||||
just-parser boa init-parser ;
|
||||
just-parser boa wrap-peg ;
|
||||
|
||||
: 1token ( ch -- parser ) 1string token ;
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ IN: peg.tests
|
|||
{ t } [
|
||||
#! Ensure a circular parser doesn't loop infinitely
|
||||
[ f , "a" token , ] seq*
|
||||
dup parsers>>
|
||||
dup peg>> parsers>>
|
||||
dupd 0 swap set-nth compile word?
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -245,12 +245,15 @@ C: <head> peg-head
|
|||
|
||||
GENERIC: (compile) ( peg -- quot )
|
||||
|
||||
: execute-parser ( word -- result )
|
||||
pos get apply-rule dup failed? [
|
||||
: process-parser-result ( result -- result )
|
||||
dup failed? [
|
||||
drop f
|
||||
] [
|
||||
input-slice swap <parse-result>
|
||||
] if ; inline
|
||||
] if ;
|
||||
|
||||
: execute-parser ( word -- result )
|
||||
pos get apply-rule process-parser-result ; inline
|
||||
|
||||
: parser-body ( parser -- quot )
|
||||
#! Return the body of the word that is the compiled version
|
||||
|
@ -323,7 +326,7 @@ TUPLE: token-parser symbol ;
|
|||
dup >r ?head-slice [
|
||||
r> <parse-result> f f add-error
|
||||
] [
|
||||
drop input-slice input-from "token '" r> append "'" append 1vector add-error f
|
||||
drop pos get "token '" r> append "'" append 1vector add-error f
|
||||
] if ;
|
||||
|
||||
M: token-parser (compile) ( peg -- quot )
|
||||
|
|
Loading…
Reference in New Issue