Fix ebnf for peg changes

db4
Chris Double 2008-03-29 00:41:41 +13:00
parent 4b353c7529
commit cca4700e49
2 changed files with 4 additions and 18 deletions

View File

@ -147,27 +147,13 @@ IN: peg.ebnf.tests
[
#! Test direct left recursion. Currently left recursion should cause a
#! failure of that parser.
#! Not using packrat, so recursion causes data stack overflow
"1+1" [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call
] must-fail
{ V{ 49 } } [
#! Test direct left recursion. Currently left recursion should cause a
#! failure of that parser.
#! Using packrat, so first part of expr fails, causing 2nd choice to be used
"1+1" [ [EBNF num=([0-9])+ expr=expr "+" num | num EBNF] call ] with-packrat parse-result-ast
] unit-test
[
#! Test indirect left recursion. Currently left recursion should cause a
#! failure of that parser.
#! Not using packrat, so recursion causes data stack overflow
#! Using packrat, so first part of expr fails, causing 2nd choice to be used
"1+1" [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call
] must-fail
{ V{ 49 } } [
#! Test indirect left recursion. Currently left recursion should cause a
#! failure of that parser.
#! Using packrat, so first part of expr fails, causing 2nd choice to be used
"1+1" [ [EBNF num=([0-9])+ x=expr expr=x "+" num | num EBNF] call ] with-packrat parse-result-ast
] unit-test

View File

@ -266,7 +266,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
] [ ] make delay sp ;
: transform-ebnf ( string -- object )
'ebnf' packrat-parse parse-result-ast transform ;
'ebnf' parse parse-result-ast transform ;
: check-parse-result ( result -- result )
dup [
@ -281,8 +281,8 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
] if ;
: ebnf>quot ( string -- hashtable quot )
'ebnf' packrat-parse check-parse-result
parse-result-ast transform dup main swap at compile 1quotation ;
'ebnf' parse check-parse-result
parse-result-ast transform dup main swap at compile [ parse ] curry ;
: [EBNF "EBNF]" parse-multiline-string ebnf>quot nip parsed ; parsing