Class IXMLAnalyzer
java.lang.Object
org.libxmq.imp.ixml.IXMLAnalyzer
Character-level LL(*) analysis and parser-description DOM. Every decision gets a
lookahead DFA, see IXMLLookahead.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic XmlDocumentAnalyze a grammar and test its predictive parser against the whole input.static IXMLAnalyzercompileParser(String source) Compile a grammar for parsing many inputs with the LL(*) parser, see parseInput.static XmlDocumentfailureDocument(byte[] buf, int begin, int stop, int failed_at, String error, List<EarleyParser.Expected> expected) The failure document of a rejected input, like failureDocument for a String, but the input is UTF-8 bytes, only the code points up to the failure and around it are decoded.static XmlDocumentfailureDocument(String input, int failed_at, String error, List<EarleyParser.Expected> expected) The failure document of a rejected input, like in the C version: ixml(ixml:state=failed){info=... line=... column=... pos=...}static booleanReturns true if the document is a failure document from parseInputOrFailure.static XmlDocumentParse the input with the LL(*) parser of the grammar and return the ixml parse tree.parseInput(String input) Parse an input with a parser from compileParser.parseInputOrFailure(String input, boolean silent) Parse an input with a parser from compileParser.
-
Field Details
-
IXML_NS
-
-
Method Details
-
analyze
Analyze a grammar and test its predictive parser against the whole input.- Parameters:
source- iXML grammarinput- sample input (not used to infer grammar properties), or null for no test- Returns:
- an analysis DOM containing diagnostics or a parser and test result
-
compileParser
Compile a grammar for parsing many inputs with the LL(*) parser, see parseInput.- Parameters:
source- iXML grammar- Returns:
- the compiled parser
- Throws:
IllegalArgumentException- if the grammar is not LL(*)
-
parseInput
Parse an input with a parser from compileParser.- Parameters:
input- the input to parse- Returns:
- the parse tree
- Throws:
IllegalArgumentException- if the input is rejected
-
parseInputOrFailure
Parse an input with a parser from compileParser. When the input is rejected, the result is a failure document, like in the C version: ixml(ixml:state=failed){info=... line=... column=... pos=...} A dynamic error, eg D02, has only the info.- Parameters:
input- the input to parsesilent- if true a rejected input gives an empty document- Returns:
- the parse tree or the failure document
-
failureDocument
public static XmlDocument failureDocument(String input, int failed_at, String error, List<EarleyParser.Expected> expected) The failure document of a rejected input, like in the C version: ixml(ixml:state=failed){info=... line=... column=... pos=...} A dynamic error, eg D02, has only the info.- Parameters:
input- the inputfailed_at- the code point position of the failureerror- the error messageexpected- what the parser could read at the position, see EarleyParser.expected- Returns:
- the failure document
-
failureDocument
public static XmlDocument failureDocument(byte[] buf, int begin, int stop, int failed_at, String error, List<EarleyParser.Expected> expected) The failure document of a rejected input, like failureDocument for a String, but the input is UTF-8 bytes, only the code points up to the failure and around it are decoded. An error starting with Earley.INVALID_UTF8 gives the failure document of the C version for an input that is not valid UTF-8, the error is then at the invalid bytes.- Parameters:
buf- the input as UTF-8begin- the first byte of the inputstop- the end of the input, exclusivefailed_at- the code point position of the failureerror- the error messageexpected- what the parser could read at the position, see EarleyParser.expected- Returns:
- the failure document
-
isFailure
Returns true if the document is a failure document from parseInputOrFailure.- Parameters:
d- the document- Returns:
- true if the root has ixml:state=failed
-
parse
Parse the input with the LL(*) parser of the grammar and return the ixml parse tree.- Parameters:
source- iXML grammarinput- the input to parse- Returns:
- the parse tree
- Throws:
IllegalArgumentException- if the grammar is not LL(*) or the input is rejected
-