|
Generic Interpreter 0.9 Protected API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gi.Lexicon
This class implements a Lexicon
.
Inner Class Summary | |
protected static class |
Lexicon.Concatenation
This class implements an denoting the concatenation of two regular languages. |
protected class |
Lexicon.Exception
This class implements an . |
protected static class |
Lexicon.Match
This class implements an denoting the set of characters in a string. |
protected static class |
Lexicon.NonMatch
This class implements an denoting the set of characters not in a string. |
protected static class |
Lexicon.PosixClass
This class implements an denoting the set of characters in a POSIX class. |
protected static class |
Lexicon.Range
This class implements an denoting the set of characters in a range. |
protected static class |
Lexicon.Repetition
This class implements an denoting the repetition of a regular language. |
protected static class |
Lexicon.Singleton
This class implements an denoting the set containing a string. |
protected static class |
Lexicon.UnicodeCategory
This class implements an denoting the set of characters in a Unicode category. |
protected static class |
Lexicon.Union
This class implements an denoting the union of two regular languages. |
Field Summary | |
protected static String |
END_OF_SOURCE
The terminal matching the character at the end of a source stream. |
Constructor Summary | |
protected |
Lexicon()
Constructs an empty Lexicon . |
Method Summary | |
protected static gi.Lexicon.Expression |
expression(String string)
Creates an Expression by interpreting a POSIX extended regular expression (ERE), as used in egrep. |
Object |
grab(BufferedReader source)
Grabs a terminal from a source character stream using this Lexicon . |
protected void |
put(Object terminal,
gi.Lexicon.Expression expression)
Puts a terminal and associated Expression into this Lexicon . |
String |
word()
Returns the word most recently grabbed using this Lexicon . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final String END_OF_SOURCE
The terminal matching the character at the end of a source stream.
Constructor Detail |
protected Lexicon()
Constructs an empty Lexicon
.
Method Detail |
protected static gi.Lexicon.Expression expression(String string) throws Lexicon.Exception
Creates an Expression
by interpreting a POSIX extended regular expression (ERE), as used in egrep. The syntax and semantics for EREs is formally specified by the ERE Grammar
. Provides a convenient method for constructing an Expression
, at the cost of an LR(1) parse. Implementations seeking maximum speed should avoid this method and use explicit Expression
subclass constructors; for example,
new Union(new NonMatch("0"), new Singleton("foo"))
instead of
Lexicon.expression("[^0]|foo")
string
- the POSIX extended regular expression (ERE) to be interpreted.Expression
constructed by interpreting string
.Lexicon.Exception
- if a syntax error occurs.public Object grab(BufferedReader source) throws Lexicon.Exception
Grabs a terminal from a source character stream using this Lexicon
. The variable returned by word()
is set to the longest nonempty prefix of the remaining source characters matching an Expression
in this Lexicon
. If no nonempty prefix matches an Expression
, a Lexicon.Exception
is thrown. If the longest matching prefix matches more than one Expression
, the terminal associated with the Expression
most recently constructed is returned. Blocks until a character is available, an I/O error occurs, or the end of the source stream is reached.
source
- the source character stream.source
.Lexicon.Exception
- if an I/O or lexical error occurs.protected void put(Object terminal, gi.Lexicon.Expression expression)
Puts a terminal and associated Expression
into this Lexicon
. The Expression
supersedes any previously associated with the terminal.
terminal
- the terminal to be added.expression
- the Expression
associated with terminal
. When grabbing, the language denoted by expression
matches terminal
.public String word()
Returns the word most recently grabbed using this Lexicon
.
grab(source)
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |