summary {gramEvol} | R Documentation |
Context-free Grammar Object Information
Description
Examines a context-free grammar object.
Usage
## S3 method for class 'grammar'
summary(object, ...)
GrammarStartSymbol(grammar)
GrammarIsRecursive(grammar, startSymb = GrammarStartSymbol(grammar), ...)
GrammarGetDepth(grammar, max.depth = max(length(grammar$def), 4),
startSymb = GrammarStartSymbol(grammar), ...)
GrammarMaxSequenceLen(grammar, max.depth = GetGrammarDepth(grammar),
startSymb = GrammarStartSymbol(grammar), ...)
GrammarMaxRuleSize(grammar)
GrammarMaxSequenceRange(grammar, max.depth = GrammarGetDepth(grammar),
startSymb = GrammarStartSymbol(grammar), approximate = FALSE, ...)
GrammarNumOfExpressions(grammar, max.depth = GrammarGetDepth(grammar),
startSymb = GrammarStartSymbol(grammar), ...)
Arguments
grammar , object |
A |
max.depth |
Maximum depth of search in case of a cyclic grammar. By default it is limited to the maximum of 4 or the number of production rules in the grammar. |
startSymb |
The symbol where the generation of a new expression should start. |
approximate |
If True, results are approximated. Useful for recursive grammars, where number of valid expressions prohibits an accurate measurement. |
... |
unused inputs. |
Value
summary
returns a summary.grammar
object, with the following slots which
are obtained from the other functions:
Start.Symbol |
|
Is.Recursive |
|
Tree.Depth |
|
Maximum.Sequence.Length |
|
Maximum.Rule.Size |
|
Maximum.Sequence.Variation |
|
No.of.Unique.Expressions |
|
See Also
Examples
# Define a simple grammar
# <expr> ::= <var><op><var>
# <op> ::= + | - | *
# <var> ::= A | B
ruleDef <- list(expr = gsrule("<var><op><var>"),
op = gsrule("+", "-", "*"),
var = gsrule("A", "B"))
# Create a grammar object
grammarDef <- CreateGrammar(ruleDef)
# summarize grammar object
summary(grammarDef)