summary.grammar: Context-free Grammar Object Information

Description Usage Arguments Value See Also Examples

View source: R/summary.grammar.R

Description

Examines a context-free grammar object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## 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), ...) 

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.

...

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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)

gramEvol documentation built on May 30, 2017, 6:08 a.m.