|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Input
interface is responsible for presenting a
raw character stream to the Lexer
in a way that makes
the lexing process easier. Since all the methods in this interface
deal with character handling, they all end in "ch". This was not
the case originally --- only getch()
was named with
the ch-suffix. But I thought fetch()
,
retch()
and strech()
were so exceedingly
clever that I converted the rest of the names to the
ch-suffix-convention.
Method Summary | |
int |
atch()
"At char" (no argument): Returns the current absolute position of the input (the offset), as though an index into an array. |
void |
atch(int offset)
"At char (with argument)": Sets the input position to the given argument. |
int |
atln()
"At line": Returns the current line number. |
void |
bach(int len)
"backup chars": Moves the input "back" the given number of characters. |
int |
broach()
Returns the forthcoming char without advancing the
buffer (like a `peek'). |
void |
fetch(int offset,
int length,
char[] dst,
int dstoff)
"Fetch chars": Copies the region from offset with given length into the dst array provided starting at the given destination offset. |
int |
getch()
"Get char": Gets the next char and advances the
offset by one. |
void |
initch(Object src)
Initialize the Input source to the given Object . |
void |
patch(int offset,
char[] src,
int srcoff,
int length)
"Patch": change the given region starting at the given offset. |
char |
retch(int offset)
"Return char": get the the char at the given
offset. |
char[] |
retch(int offset,
int length)
"Return chars": Gets the region from offset to length as a new character array. |
String |
stretch(int offset,
int length)
"Return chars as String": fetches the stretch of characters from offset to length as a new string. |
Method Detail |
public void initch(Object src) throws IOException
Object
.public int broach()
char
without advancing the
buffer (like a `peek'). If the end of the buffer has been
reached, -1
is returned.public int getch() throws EOFException, IOException
char
and advances the
offset by one. If the end of input symbol has already been
returned and getch() is called again, EOFException
is thrown. Underlying IOExceptions
that may occur
are delegated to the caller.public void bach(int len)
ungetch(3)
would move the input
pointer back three characters and therefore to the beginning
(just before 'a').public char[] retch(int offset, int length)
ArrayIndexOutOfBoundsException
- if the
region ifs not valid.public char retch(int offset)
char
at the given
offset.public String stretch(int offset, int length)
ArrayIndexOutOfBoundsException
- if the
region ifs not valid.public void fetch(int offset, int length, char[] dst, int dstoff)
ArrayIndexOutOfBoundsException
- if the
region ifs not valid.public void patch(int offset, char[] src, int srcoff, int length)
public int atch()
public void atch(int offset)
public int atln()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |