Throw error when ebnf uses a non-existant non-terminal

db4
Chris Double 2008-04-01 14:49:20 +13:00
parent 72bfd57f30
commit 122fd50d4a
1 changed files with 6 additions and 1 deletions

View File

@ -310,9 +310,14 @@ M: ebnf-var (transform) ( ast -- parser )
M: ebnf-terminal (transform) ( ast -- parser )
symbol>> token sp ;
: parser-not-found ( name -- * )
[
"Parser " % % " not found." %
] "" make throw ;
M: ebnf-non-terminal (transform) ( ast -- parser )
symbol>> [
, parser get , \ at , \ sp ,
, \ dup , parser get , \ at , [ parser-not-found ] , \ unless* , \ sp , \ nip ,
] [ ] make box ;
: transform-ebnf ( string -- object )