Class IXMLGenerateC
java.lang.Object
org.libxmq.imp.ixml.IXMLGenerateC
Generate a C parser from an LL(*) ixml grammar.
The generated parser is a top down recursive descent parser. Every rule is
a C function, every decision (a rule with more than one alternative) is
predicted by its lookahead DFA from IXMLLookahead. Since the prediction is
exact there is no backtracking, so the ixml parse tree is built while
parsing, through the macros XMQ_ADD_ROOT_ELEMENT, XMQ_ADD_ELEMENT,
XMQ_SET_ATTRIBUTE and XMQ_ADD_TEXT which by default use libxmq.
The generated file also contains a main function (unless compiled with
-DXMQ_PARSER_NO_MAIN) that parses a file or stdin and prints the tree like
xmq does, so that: xmq grammar.ixml input.txt
and: ./grammar_parser input.txt
print the same.
-
Method Summary
-
Method Details
-
generate
Generate the C source of a parser for the grammar.- Parameters:
source- The ixml grammar.prefix- The prefix of the generated C names, eg xmqcli gives xmqcli_parse.source_name- The grammar file name, used in comments.- Returns:
- The C source code.
- Throws:
IllegalArgumentException- if the grammar is not LL(*).
-