Modifier and Type | Class and Description |
---|---|
static class |
Grammars.Dependencies
Represents the dependencies between the various non-terminals
in some grammar.
|
static class |
Grammars.NTermsInfo
Gathers the result of the computation of the
NULLABLE, FIRST and FOLLOW sets on non-terminals
in a given grammar
|
static class |
Grammars.PredictionTable
Instances of this class hold a prediction table for some
grammar.
|
Modifier and Type | Method and Description |
---|---|
static Grammars.NTermsInfo |
analyseGrammar(Grammar grammar,
@Nullable Grammars.Dependencies deps_,
@Nullable Reporter reporter)
Analyze the given
grammar and compute for every non-terminal
whether it is nullable, and the associated FIRST and FOLLOW
sets. |
static Grammars.Dependencies |
dependencies(Grammar grammar)
Computes the map of dependencies between the non-terminals
of the given grammar, i.e. associates to every non-terminal in
grammar the set of non-terminals which appear in the
right-hand side of productions for this non-terminal. |
protected static Map<String,Set<String>> |
first(Grammars.Dependencies deps,
Grammar grammar,
Set<String> nullable) |
protected static Map<String,Set<String>> |
follow(Grammars.Dependencies deps,
Grammar grammar,
Set<String> nullable,
Map<String,Set<String>> first) |
protected static Set<String> |
nullable(Grammars.Dependencies deps,
Grammar grammar)
NB: In all generality this is only a correct approximation, so
non-terminals which are not in the resulting state are not guaranteed
to always produce non-empty matches.
|
static Grammars.PredictionTable |
predictionTable(Grammar grammar,
Grammars.NTermsInfo infos)
Constructs a prediction table for the given grammar.
|
public static Grammars.Dependencies dependencies(Grammar grammar)
grammar
the set of non-terminals which appear in the
right-hand side of productions for this non-terminal.grammar
- protected static Set<String> nullable(Grammars.Dependencies deps, Grammar grammar)
deps
- grammar
- grammar
which can produce empty sequence of tokensprotected static Map<String,Set<String>> first(Grammars.Dependencies deps, Grammar grammar, Set<String> nullable)
protected static Map<String,Set<String>> follow(Grammars.Dependencies deps, Grammar grammar, Set<String> nullable, Map<String,Set<String>> first)
public static Grammars.NTermsInfo analyseGrammar(Grammar grammar, @Nullable Grammars.Dependencies deps_, @Nullable Reporter reporter)
grammar
and compute for every non-terminal
whether it is nullable, and the associated FIRST and FOLLOW
sets. If reporter
is non-null
, this also returns
potentially unused symbols discovered during the analysis of the grammar.grammar
- deps_
- null
, or dependencies already computed for
the given grammarreporter
- an instance to report problems to, or null
if no problem report is desiredpublic static Grammars.PredictionTable predictionTable(Grammar grammar, Grammars.NTermsInfo infos)
infos
.grammar
- infos
- grammar