|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jruby.lexer.yacc.LexerSource
This class is what feeds the lexer. It is primarily a wrapper around a Reader that can unread() data back onto the source. Originally, I thought about using the PushBackReader to handle read/unread, but I realized that some extremely pathological case could overflow the pushback buffer. Better safe than sorry. I could have combined this implementation with a PushbackBuffer, but the added complexity did not seem worth it.
Constructor Summary | |
LexerSource(java.lang.String sourceName,
java.io.Reader reader,
int line)
Create our food-source for the lexer |
|
LexerSource(java.lang.String sourceName,
java.io.Reader reader,
ISourcePositionFactory factory)
|
Method Summary | |
char |
getCharAt(int anOffset)
Get character ahead of current position by offset positions. |
int |
getColumn()
Are we at beggining of line? |
java.lang.String |
getFilename()
What file are we lexing? |
int |
getLine()
What line are we at? |
int |
getOffset()
The location of the last byte we read from the source. |
ISourcePosition |
getPosition()
Where is the reader within the source {filename,row} |
ISourcePosition |
getPosition(ISourcePosition startPosition,
boolean inclusive)
Where is the reader within the source {filename,row} |
ISourcePositionFactory |
getPositionFactory()
|
static LexerSource |
getSource(java.lang.String name,
java.io.Reader content,
int line)
Create a source. |
boolean |
matchString(java.lang.String match,
boolean indent)
|
boolean |
peek(char to)
|
char |
read()
Read next character from this source |
char |
readEscape()
|
java.lang.String |
readLine()
|
ByteList |
readLineBytes()
|
java.lang.String |
toString()
|
void |
unread(char c)
Pushes char back onto this source. |
void |
unreadMany(java.lang.CharSequence buffer)
|
boolean |
wasBeginOfLine()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public LexerSource(java.lang.String sourceName, java.io.Reader reader, int line)
sourceName
- is the file we are readingreader
- is what represents the contents of file sourceNameline
- starting line number for source (used by eval)public LexerSource(java.lang.String sourceName, java.io.Reader reader, ISourcePositionFactory factory)
Method Detail |
public char read() throws java.io.IOException
java.io.IOException
public void unread(char c)
c
- to be put back onto the sourcepublic boolean peek(char to) throws java.io.IOException
java.io.IOException
public java.lang.String getFilename()
public int getLine()
public int getColumn()
public int getOffset()
public ISourcePosition getPosition(ISourcePosition startPosition, boolean inclusive)
public ISourcePosition getPosition()
public ISourcePositionFactory getPositionFactory()
public static LexerSource getSource(java.lang.String name, java.io.Reader content, int line)
name
- the name of the source (e.g a filename: foo.rb)content
- the data of the source
public java.lang.String readLine() throws java.io.IOException
java.io.IOException
public ByteList readLineBytes() throws java.io.IOException
java.io.IOException
public void unreadMany(java.lang.CharSequence buffer)
public boolean matchString(java.lang.String match, boolean indent) throws java.io.IOException
java.io.IOException
public boolean wasBeginOfLine()
public char readEscape() throws java.io.IOException
java.io.IOException
public char getCharAt(int anOffset) throws java.io.IOException
anOffset
- is location past current position to get char at
java.io.IOException
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |