public class MergeByWeightParser extends java.lang.Object implements Parser
Modifier and Type | Field and Description |
---|---|
protected @NotNull java.util.List<Parser> |
parsers
The parsers in order.
|
Constructor and Description |
---|
MergeByWeightParser(@NotNull java.util.List<Parser> parsers)
Construct a new parser that uses the given
parsers preferring the results
from the parsers at the start that the results from the parsers that at the end
when a clash occur between their results. |
MergeByWeightParser(Parser... parsers)
Construct a new parser that uses the given
parsers preferring the results
from the parsers at the start that the results from the parsers that at the end
when a clash occur between their results. |
Modifier and Type | Method and Description |
---|---|
protected boolean |
check(@NotNull Tree primary,
@NotNull Tree secondary)
Check if the down-structure of the given
secondary can be alongside with
the given primary in its structure. |
@NotNull java.util.Set<Tree> |
parse(@NotNull Compilation compilation,
@NotNull Tree tree)
Parse the given
sketch with respect to the given compilation . |
@NotNull protected final @NotNull java.util.List<Parser> parsers
public MergeByWeightParser(@Nullable Parser... parsers)
parsers
preferring the results
from the parsers at the start that the results from the parsers that at the end
when a clash occur between their results.
parsers
- the parsers to be used by the constructed parser.java.lang.NullPointerException
- if the given parsers
is null.public MergeByWeightParser(@NotNull @NotNull java.util.List<Parser> parsers)
parsers
preferring the results
from the parsers at the start that the results from the parsers that at the end
when a clash occur between their results.
parsers
- the parsers to be used by the constructed parser.java.lang.NullPointerException
- if the given parsers
is null.@NotNull public @NotNull java.util.Set<Tree> parse(@NotNull @NotNull Compilation compilation, @NotNull @NotNull Tree tree)
Parser
sketch
with respect to the given compilation
.@Contract(pure=true) protected boolean check(@NotNull @NotNull Tree primary, @NotNull @NotNull Tree secondary)
secondary
can be alongside with
the given primary
in its structure.primary
- the primary tree that is always wins.secondary
- the slave tree that might win or might lose depending on if it
clashes with the primary or not.secondary
can be with the given primary
.java.lang.NullPointerException
- if the given primary
or secondary
is
null.