diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor index 399b5b0fc9..91af91b3a1 100644 --- a/basis/peg/ebnf/ebnf.factor +++ b/basis/peg/ebnf/ebnf.factor @@ -5,7 +5,7 @@ sequences quotations vectors namespaces make math assocs continuations peg peg.parsers unicode.categories multiline splitting accessors effects sequences.deep peg.search combinators.short-circuit lexer io.streams.string stack-checker -io combinators parser ; +io combinators parser call ; IN: peg.ebnf : rule ( name word -- parser ) @@ -36,7 +36,7 @@ TUPLE: tokenizer any one many ; : TOKENIZER: scan search [ "Tokenizer not found" throw ] unless* - execute \ tokenizer set-global ; parsing + execute( -- tokenizer ) \ tokenizer set-global ; parsing TUPLE: ebnf-non-terminal symbol ; TUPLE: ebnf-terminal symbol ; @@ -391,7 +391,7 @@ M: ebnf-choice (transform) ( ast -- parser ) options>> [ (transform) ] map choice ; M: ebnf-any-character (transform) ( ast -- parser ) - drop tokenizer any>> call ; + drop tokenizer any>> call( -- parser ) ; M: ebnf-range (transform) ( ast -- parser ) pattern>> range-pattern ; @@ -469,17 +469,17 @@ ERROR: bad-effect quot effect ; M: ebnf-action (transform) ( ast -- parser ) [ parser>> (transform) ] [ code>> insert-escapes ] [ parser>> ] tri build-locals - string-lines parse-lines check-action-effect action ; + [ string-lines parse-lines ] call( string -- quot ) check-action-effect action ; M: ebnf-semantic (transform) ( ast -- parser ) [ parser>> (transform) ] [ code>> insert-escapes ] [ parser>> ] tri build-locals - string-lines parse-lines semantic ; + [ string-lines parse-lines ] call( string -- quot ) semantic ; M: ebnf-var (transform) ( ast -- parser ) parser>> (transform) ; M: ebnf-terminal (transform) ( ast -- parser ) - symbol>> tokenizer one>> call ; + symbol>> tokenizer one>> call( symbol -- parser ) ; M: ebnf-foreign (transform) ( ast -- parser ) dup word>> search @@ -487,7 +487,7 @@ M: ebnf-foreign (transform) ( ast -- parser ) swap rule>> [ main ] unless* over rule [ nip ] [ - execute + execute( -- parser ) ] if* ; : parser-not-found ( name -- * ) diff --git a/basis/peg/peg-tests.factor b/basis/peg/peg-tests.factor index 9a15dd2105..7d5cb1e76a 100644 --- a/basis/peg/peg-tests.factor +++ b/basis/peg/peg-tests.factor @@ -5,6 +5,8 @@ USING: kernel tools.test strings namespaces make arrays sequences peg peg.private peg.parsers accessors words math accessors ; IN: peg.tests +\ parse must-infer + [ ] [ reset-pegs ] unit-test [ diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index 5ac62239d7..01891a1da1 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -4,7 +4,7 @@ USING: kernel sequences strings fry namespaces make math assocs io vectors arrays math.parser math.order vectors combinators classes sets unicode.categories compiler.units parser words quotations effects memoize accessors locals effects splitting -combinators.short-circuit generalizations ; +combinators.short-circuit generalizations call ; IN: peg TUPLE: parse-result remaining ast ; @@ -298,7 +298,7 @@ SYMBOL: delayed #! Work through all delayed parsers and recompile their #! words to have the correct bodies. delayed get [ - call compile-parser 1quotation (( -- result )) define-declared + call( -- parser ) compile-parser 1quotation (( -- result )) define-declared ] assoc-each ; : compile ( parser -- word ) @@ -309,7 +309,7 @@ SYMBOL: delayed ] with-compilation-unit ; : compiled-parse ( state word -- result ) - swap [ execute [ error-stack get first throw ] unless* ] with-packrat ; inline + swap [ execute( -- result ) [ error-stack get first throw ] unless* ] with-packrat ; : (parse) ( input parser -- result ) dup word? [ compile ] unless compiled-parse ; @@ -527,7 +527,7 @@ M: box-parser (compile) ( peg -- quot ) #! to produce the parser to be compiled. #! This differs from 'delay' which calls #! it at run time. - quot>> call compile-parser 1quotation ; + quot>> call( -- parser ) compile-parser 1quotation ; PRIVATE> diff --git a/basis/peg/search/search-tests.factor b/basis/peg/search/search-tests.factor index b22a5ef0d0..96d89d4611 100644 --- a/basis/peg/search/search-tests.factor +++ b/basis/peg/search/search-tests.factor @@ -17,3 +17,5 @@ IN: peg.search.tests "abc 123 def 456" 'integer' [ 2 * number>string ] action replace ] unit-test +\ search must-infer +\ replace must-infer