From 122fd50d4a7fee989bdcf69dc699d7bcf4246600 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Tue, 1 Apr 2008 14:49:20 +1300 Subject: [PATCH] Throw error when ebnf uses a non-existant non-terminal --- extra/peg/ebnf/ebnf.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index 26e5d68df8..a6567ce8f3 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -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 )