Modifier and Type | Class and Description |
---|---|
static class |
PGrammars.Args
Enumeration representing the different constraints which can exist
on the arguments of a symbol in a grammar: arguments can either
be mandatory, forbidden, or there may be no constraint at all.
|
static class |
PGrammars.Dependencies
Represents the dependencies between the various non-terminals
in some grammar.
|
static class |
PGrammars.Sort
This enumeration describes the various sorts which can characterize
the kind of terminals or non-terminals (or more generally actual
expressions) that can stand for some formal parameter in a parametric
grammar.
|
Modifier and Type | Method and Description |
---|---|
static Map<String,List<PGrammars.Sort>> |
analyseGrammar(PGrammar grammar,
@Nullable PGrammars.Dependencies dependencies_,
Reporter reporter)
This analyses various rule applications in the parametric
grammar
grammar by inferring sorts
for all the rules' formal parameters and checking that
effective parameters in all applications are abiding by
the constraints expressed by the sorts. |
static PGrammars.Dependencies |
dependencies(Map<String,PGrammarRule> rules)
Computes the map of dependencies between the non-terminals
of the given grammar rules, i.e. associates to every non-terminal in
rules the set of non-terminals which appear in the
right-hand side of productions for this non-terminal. |
static void |
findUnusedSymbols(PGrammar grammar,
PGrammars.Dependencies deps,
Reporter reporter)
Analyses the
grammar 's dependencies deps to
determine non-terminals and terminals which are not really being
used in this grammar description. |
public static PGrammars.Dependencies dependencies(Map<String,PGrammarRule> rules)
rules
the set of non-terminals which appear in the
right-hand side of productions for this non-terminal.rules
- public static void findUnusedSymbols(PGrammar grammar, PGrammars.Dependencies deps, Reporter reporter)
grammar
's dependencies deps
to
determine non-terminals and terminals which are not really being
used in this grammar description.
For terminals, this amounts to not being used in any production, whereas for non-terminals, it means not being used transitively by a public non-terminal (in particular blocks of mutually recursive private non-terminals dot not "justify" each other, nor does continuation in a given non-terminal of course).
The problems found, if any, are reported into reporter
.
grammar
- deps
- reporter
- public static Map<String,List<PGrammars.Sort>> analyseGrammar(PGrammar grammar, @Nullable PGrammars.Dependencies dependencies_, Reporter reporter)
grammar
by inferring sorts
for all the rules' formal parameters and checking that
effective parameters in all applications are abiding by
the constraints expressed by the sorts.
All problems found are reported in reporter
.
grammar
- dependencies_
- the dependencies
between non-terminals in grammar
, or null
if the dependencies should be computed by the methodreporter
- grammar
(even non-parametric ones) to the list of sorts that have been
inferred for its formal parameters