Learn R Programming

gramEvol (version 2.1-4)

summary: Context-free Grammar Object Information

Description

Examines a context-free grammar object.

Usage

# S3 method for 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 grammar object.

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

GrammarStartSymbol returns the grammar's starting symbol.

Is.Recursive

GrammarIsRecursive returns TRUE if grammar contains a recursive element.

Tree.Depth

GrammarGetDepth returns the depth of the grammar. It is limited to max.depth for a recursive grammar.

Maximum.Sequence.Length

GrammarMaxSequenceLen returns the maximum length of a sequence needed to generate an expression without wrapping.

Maximum.Rule.Size

GrammarMaxRuleSize returns the largest rule size in the grammar.

Maximum.Sequence.Variation

GrammarMaxSequenceRange returns a numeric sequence, with each of its elements holding the highest range that the same position in all sequences can hold.

No.of.Unique.Expressions

GrammarNumOfExpressions returns the number of expressions a grammar can generate.

See Also

CreateGrammar, GrammarMap

Examples

Run this code
# NOT RUN {
# 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)
# }

Run the code above in your browser using DataLab