debugging, documentation for peg-lexer

db4
Sam Anklesaria 2009-03-10 16:14:39 -05:00
parent cccaff40b1
commit 995d28fb2f
2 changed files with 15 additions and 4 deletions

View File

@ -0,0 +1,11 @@
USING: peg.ebnf help.syntax help.markup strings ;
IN: peg-lexer
ABOUT: "peg-lexer"
HELP: ON-BNF:
{ $syntax "ON-BNF: word ... ;ON-BNF" }
{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack. Parser syntax is as in " { $link POSTPONE: EBNF: } } ;
HELP: create-bnf
{ $values { "word" string } { "parser" parser } }
{ $description "Runtime equivalent of ON-BNF- also useful with manually constructed parsers." } ;

View File

@ -38,11 +38,11 @@ M: lex-hash at* swap {
[ execute [ error-stack get first throw ] unless* ] with-global-lexer
ast>> ;
: create-bnf ( name parser -- ) [ lexer get skip-blank parse* dup V{ } = [ parsed ] unless ] curry
define POSTPONE: parsing ;
: create-bnf ( name parser -- ) reset-tokenizer [ lexer get skip-blank parse* dup V{ } = [ parsed ] unless ] curry
define word make-parsing ;
: ON-BNF: CREATE-WORD reset-tokenizer ";ON-BNF" parse-multiline-string parse-ebnf
main swap at reset-tokenizer create-bnf ; parsing
main swap at create-bnf ; parsing
! Tokenizer like standard factor lexer
EBNF: factor