Add <EBNF ... ENBF> syntax to return a parser object
parent
8aa7bc6d78
commit
4c1fe8f0b3
|
@ -518,11 +518,16 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
|
||||||
"Could not parse EBNF" throw
|
"Could not parse EBNF" throw
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
: parse-ebnf ( string -- hashtable )
|
||||||
|
'ebnf' parse check-parse-result ast>> transform ;
|
||||||
|
|
||||||
: ebnf>quot ( string -- hashtable quot )
|
: ebnf>quot ( string -- hashtable quot )
|
||||||
'ebnf' parse check-parse-result
|
parse-ebnf dup dup parser [ main swap at compile ] with-variable
|
||||||
parse-result-ast transform dup dup parser [ main swap at compile ] with-variable
|
|
||||||
[ compiled-parse ] curry [ with-scope ] curry ;
|
[ compiled-parse ] curry [ with-scope ] curry ;
|
||||||
|
|
||||||
|
: <EBNF "EBNF>" reset-tokenizer parse-multiline-string parse-ebnf main swap at
|
||||||
|
parsed reset-tokenizer ; parsing
|
||||||
|
|
||||||
: [EBNF "EBNF]" reset-tokenizer parse-multiline-string ebnf>quot nip
|
: [EBNF "EBNF]" reset-tokenizer parse-multiline-string ebnf>quot nip
|
||||||
parsed \ call parsed reset-tokenizer ; parsing
|
parsed \ call parsed reset-tokenizer ; parsing
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue