compiler.crossref:generic-call-site-crossref
compiler-impl
compiler.errors:compiler-errors
- lexer-factory
print-use-hook
root-cache
require-when-vocabs
{ $values { "lexer" lexer } { "quot" quotation } { "newquot" quotation } }
{ $description "Calls the quotation with the " { $link lexer } " variable set to the given lexer. The quotation can make use of words such as " { $link scan-token } ". Any errors thrown by the quotation are wrapped in " { $link lexer-error } " instances." } ;
-HELP: lexer-factory
-{ $var-description "A variable holding a quotation with stack effect " { $snippet "( lines -- lexer )" } ". This quotation is called by the parser to create " { $link lexer } " instances. This variable can be rebound to a quotation which outputs a custom tuple delegating to " { $link lexer } " to customize syntax." } ;
-
-
ARTICLE: "parser-lexer" "The lexer"
"A variable that encapsulate internal parser state:"
{ $subsections lexer }
: with-lexer ( lexer quot -- newquot )
[ lexer set ] dip [ <lexer-error> rethrow ] recover ; inline
-
-SYMBOL: lexer-factory
-
-[ <lexer> ] lexer-factory set-global
[ f parse-until >quotation ] with-lexer ;
: parse-lines ( lines -- quot )
- lexer-factory get call( lines -- lexer ) (parse-lines) ;
+ <lexer> (parse-lines) ;
: parse-literal ( accum end quot -- accum )
[ parse-until ] dip call suffix! ; inline