|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hdcookbook.grin.io.text.Lexer
public class Lexer
Read tokens from a file. This is used by the various parsers.
It reads various kinds of tokens on demand, and throws an IOException with a plausible error message on a lexing error. It makes no attempt to recover from errors, so parsers will need to stop on the first error. Methods:
Constructor Summary | |
---|---|
Lexer(java.io.Reader input,
java.lang.String fileName,
ShowParser parser)
|
Method Summary | |
---|---|
double |
convertToDouble(java.lang.String tok)
|
int |
convertToInt(java.lang.String tok)
|
void |
expectString(java.lang.String expected,
java.lang.String tok)
Expect to see a certain string. |
boolean |
getBoolean()
|
double |
getDouble()
|
java.lang.String |
getFileName()
Get the name of the main show file being read. |
int |
getInt()
|
int |
getIntOrInfinite()
|
int |
getIntOrOffscreen()
|
int |
getLineNumber()
Get the current line number within the main show file. |
ShowParser |
getParser()
Get the main ShowParser we're lexing for. |
java.lang.String |
getString()
|
java.lang.String |
getStringExact()
Gets the next string that's the exact contents of the next bit of the input stream. |
void |
parseExpected(java.lang.String expected)
Parses a token that we expect to see. |
void |
reportError(java.lang.String msg)
Report a nice error message with the current line number. |
void |
reportWarning(java.lang.String msg)
Give a warning with the current line number |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Lexer(java.io.Reader input, java.lang.String fileName, ShowParser parser)
Method Detail |
---|
public ShowParser getParser()
public void reportError(java.lang.String msg) throws java.io.IOException
java.io.IOException
public void reportWarning(java.lang.String msg)
public int getLineNumber()
public java.lang.String getFileName()
public int getInt() throws java.io.IOException
java.io.IOException
public double getDouble() throws java.io.IOException
java.io.IOException
public int getIntOrInfinite() throws java.io.IOException
java.io.IOException
public int getIntOrOffscreen() throws java.io.IOException
java.io.IOException
public int convertToInt(java.lang.String tok) throws java.io.IOException
java.io.IOException
public double convertToDouble(java.lang.String tok) throws java.io.IOException
java.io.IOException
public boolean getBoolean() throws java.io.IOException
java.io.IOException
public java.lang.String getString() throws java.io.IOException
java.io.IOException
- on any unexpected characterspublic java.lang.String getStringExact() throws java.io.IOException
This method was added to the lexer in order to read the java code between a "[[" and a "]]".
java.io.IOException
public void parseExpected(java.lang.String expected) throws java.io.IOException
java.io.IOException
public void expectString(java.lang.String expected, java.lang.String tok) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |