func mk_parser(start_rule, extra_keywords, extra_symbols):
This is a DSL implementation function for building parsers according to an Earlry grammar, where text is parsed according to the normal Converge tokenizer. Extra keywords and extra symbols that the tokenizer should recognise can be passed as lists of strings. start_rule
specifies the top rule of the grammar. This function returns a quasi-quoted function which when spliced in takes two arguments dsl_block
and src_infos
and returns a parse tree of the DSL block. An example use is as follows:
parse := $<<DSL::mk_parser("rule", ["tok", "tok2"], [])>>: rule ::= a ( b )* a ::= "TOK" | b ::= "TOK2" func my_dsl(dsl_block, src_infos) parse_tree := parse(dsl_block, src_infos) ... $<<my_dsl>>: ...
cvd_to_html ©2006-2007 Laurence Tratt