|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The ContextFreeGrammar
interface is a factory for
assembling context free grammars, analogous to the
RegularGrammar
interface. Each newXXX
method allocates and returns a construct used in defining context
free grammars. When complete, the ContextFreeSet
object is obtained via the compile()
method, which
compiles the state of the grammar into a form more amenable to set
operations (which are generally implemented using bit vectors).
Method Summary | |
ContextFreeSet |
compile()
When the construction and setup of the context free language elements is complete, compile() returns a
ContextFreeSet object which can then be used to
construct a DPA . |
Epsilon |
getEpsilon()
Returns the Epsilon object if needed. |
NonTerminal |
newNonTerminal(String name)
Allocates and returns a new NonTerminal with the
given name. |
Production |
newProduction(NonTerminal nonTerminal)
Allocates and returns a new Production on the
given LHS NonTerminal and predefined length. |
Terminal |
newTerminal(Token type)
Allocates and returns a new Terminal based on the
given Token . |
void |
setStartProduction(Production start)
Sets the start production to the given production. |
Method Detail |
public Terminal newTerminal(Token type)
Terminal
based on the
given Token
. This method is pragmatically
particularly important for the following reason: One generally
defines a Lexer
using a
RegularGrammar
and a Parser
with a
ContextFreeGrammar
. By defining our
Terminal
s based on token
s, the link
from the Lexer
to the Parser
is made.
In other words, the output of a Lexer
(token based
in the regular grammar) forms the input for the
Parser
(as terminal
s). Thus, this
method is the compile-time link between the Lexer
and Parser
.public NonTerminal newNonTerminal(String name)
NonTerminal
with the
given name.public Production newProduction(NonTerminal nonTerminal)
Production
on the
given LHS NonTerminal
and predefined length.public Epsilon getEpsilon()
Epsilon
object if needed.public void setStartProduction(Production start)
public ContextFreeSet compile()
compile()
returns a
ContextFreeSet
object which can then be used to
construct a DPA
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |