class Grammar extends AnyRef
A (context-free) grammar of productions
The preferred construction method is via the companion object's apply method, which is variadic.
A Grammar is represented by ;-delimited, newline-separated Productions:
scala> val g = new Grammar(Seq(new Production(Nonterminal('A), Alternation(Terminal("abc"), Option(Nonterminal('B)))))).format g: String = <A> ::= 'abc'|[<B>] ;
- See also
- Alphabetic
- By Inheritance
- Grammar
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
Grammar(_rules: Seq[Production])
create a new Grammar
create a new Grammar
- _rules
the sequence of Productions
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
- Definition Classes
- Grammar → AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
format: String
Returns a formatted version of this
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isWellFormed: Boolean
true iff all non-terminals on the right side of a production are also on the left side of a production
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nonterminals: Set[Nonterminal]
A set of nonterminals present in the grammar
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
val
rules: Seq[Production]
The rules of the Grammar
The rules of the Grammar
Any original rules with the same Nonterminal left-hand side are collapsed into alternations:
scala> val g = Grammar('A ::= "abc", 'A ::= "def").format g: String = <A> ::= 'abc'|'def' ;
Rather than expose the original constructor parameter, we apply a grouping and then branchify the groups in order to create a "simplified" (but more manageable) grammar.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- Grammar → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )