public class CharacterParser extends SinglePhase
parse(MemScanner,CharsRegExp,ResultingStructure)
.
The parsing is nondeterministically (implemented as parallel search)
and delivers one of the resulting interpretations which consume most input
characters.MemScanner.accept_greedy_filtered_chars(CharSet)
,
MemScanner.accept_one_filtered_char(CharSet)
,
MemScanner.accept_blanks_filtered()
,
MemScanner.accept_string_w_o_lineswitch(String)
.
Modifier and Type | Class and Description |
---|---|
protected static class |
CharacterParser.ParseResult
A simple wrapper for one (of the many parallel) parsing situations; wraps
MemScanner as the next input situation and ResultingStructure s
as collected so far. |
Modifier and Type | Field and Description |
---|---|
protected Navigate.CharSetCalc |
charSetCalc |
protected boolean |
doTrace |
protected Set<CharacterParser.ParseResult> |
hypotheses
Set of alive parsing situations: is input before visiting a grammar sub-expression
and output after parsing.
|
protected MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> |
msg |
_visitor_debug_stream, partial
Constructor and Description |
---|
CharacterParser(Navigate.CharSetCalc charSetCalc,
MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg,
boolean doTrace)
Only constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
acceptCharRep(CharSet cset,
boolean isstar,
boolean istight)
Provides special treatment (implemented directly in the scanner),
including different semantics (greedy, not non-determinstically !)
for character set expressions.
|
protected void |
acceptRep(GrUnary expr,
boolean isstar) |
void |
action(Alt expr) |
void |
action(CharBinary expr) |
void |
action(CharExpr expr) |
void |
action(CharsRegExp def) |
void |
action(Enumeration enumeration)
treat enumeration as parser and create a special resulting structure.
|
void |
action(Greedy greedy)
Only the longest matches for each incoming hypotheses are recognized.
|
void |
action(ImportItem def) |
void |
action(Insertion insertion)
Special case of insertion, namely the reference to an enumeration,
can survive the rewriting process: (@ ref).
|
void |
action(Opt expr) |
void |
action(ParseParticle pp) |
void |
action(Perm permutation) |
void |
action(Plus expr) |
void |
action(Reference ref) |
void |
action(Seq expr) |
void |
action(Star expr) |
void |
action(StringConst expr) |
void |
action(TagsRegExp def) |
protected void |
copyContentsFromTo(CharacterParser.ParseResult from,
MemScanner startpos,
ResultingStructure to)
If "from" has structured contents, then add this into "to", as a sequence
and per assoc.
|
protected void |
flattened_consumption_of_enum(Enumeration enumeration)
when called from an insertion:
treat an enumeration as mere collection of string constants,
i.e.
|
static <S,T> Set<T> |
map(Function<S,T> f,
Set<S> orig) |
ResultingStructure |
parse(MemScanner scanner,
CharsRegExp parser,
ResultingStructure result)
Central executive method.
|
protected void |
subElement(Definition def,
Expression rule)
Called when reaching a ParseParticle, a CharsRegExp or an Enumeration, which all
lead to wrapping the parsing result into a Result object with this definition as its tag.
|
protected void |
trace(Location<XMLDocumentIdentifier> loc,
String s) |
protected void |
trace(String s) |
protected void |
typingError(Location<XMLDocumentIdentifier> loc) |
action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action, action
_visitor_trace, action, action, action, action, foreignObject, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, match, nomatch
protected final MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg
protected final Navigate.CharSetCalc charSetCalc
protected final boolean doTrace
protected Set<CharacterParser.ParseResult> hypotheses
public CharacterParser(Navigate.CharSetCalc charSetCalc, MessageReceiver<SimpleMessage<XMLDocumentIdentifier>> msg, boolean doTrace)
Text2Udom
does not.)public ResultingStructure parse(MemScanner scanner, CharsRegExp parser, ResultingStructure result)
CharsRegExp
definition and tries to match the
character input (given by the MemScanner
) by a non-deterministic,
parallel breadth-first execution.#RarseResult
objects combining parser state and
the ResultingStructure
, as constructed so far.protected void copyContentsFromTo(CharacterParser.ParseResult from, MemScanner startpos, ResultingStructure to)
protected void typingError(Location<XMLDocumentIdentifier> loc)
protected void trace(String s)
protected void trace(Location<XMLDocumentIdentifier> loc, String s)
public void action(Insertion insertion)
action
in class SinglePhase
public void action(Perm permutation)
action
in class SinglePhase
public void action(Reference ref)
action
in class SinglePhase
protected void flattened_consumption_of_enum(Enumeration enumeration)
public void action(Enumeration enumeration)
action
in class SinglePhase
protected void subElement(Definition def, Expression rule)
public void action(CharsRegExp def)
action
in class SinglePhase
public void action(ParseParticle pp)
action
in class SinglePhase
public void action(TagsRegExp def)
action
in class SinglePhase
public void action(ImportItem def)
action
in class SinglePhase
protected void acceptCharRep(CharSet cset, boolean isstar, boolean istight)
protected void acceptRep(GrUnary expr, boolean isstar)
public void action(Star expr)
action
in class SinglePhase
public void action(Plus expr)
action
in class SinglePhase
public void action(Greedy greedy)
action
in class SinglePhase
public void action(Opt expr)
action
in class SinglePhase
public void action(Alt expr)
action
in class SinglePhase
public void action(Seq expr)
action
in class SinglePhase
public void action(CharBinary expr)
action
in class SinglePhase
public void action(CharExpr expr)
action
in class SinglePhase
public void action(StringConst expr)
action
in class SinglePhase
see also the complete user documentation .