|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jrubyparser.lexer.LexerSource
public abstract class 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.
| Field Summary | |
|---|---|
protected int |
line
|
protected int |
offset
|
| Constructor Summary | |
|---|---|
protected |
LexerSource(String sourceName,
int line)
Create our food-source for the lexer |
| Method Summary | |
|---|---|
abstract int |
chompReadAhead()
|
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. |
SourcePosition |
getPosition()
Where is the reader within the source {filename,row} |
SourcePosition |
getPosition(SourcePosition startPosition,
boolean inclusive)
Where is the reader within the source {filename,row} |
static LexerSource |
getSource(String name,
Reader content,
ParserConfiguration configuration)
Create a source. |
abstract boolean |
isANewLine()
|
abstract boolean |
lastWasBeginOfLine()
|
abstract boolean |
matchMarker(String marker,
boolean indent,
boolean withNewline)
Match marker against input consumering lexer source as it goes...Unless it does not match then it reverts lexer source back to point when this method was invoked. |
abstract boolean |
peek(int c)
|
abstract int |
read()
|
abstract String |
readLineBytes()
|
abstract String |
readUntil(char c)
|
abstract void |
setIsANewLine(boolean nextCharIsOnANewLine)
|
abstract void |
setOffset(int offset)
|
abstract int |
skipUntil(int c)
|
abstract void |
unread(int c)
|
abstract void |
unreadMany(CharSequence line)
|
abstract boolean |
wasBeginOfLine()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int line
protected int offset
| Constructor Detail |
|---|
protected LexerSource(String sourceName,
int line)
sourceName - is the file we are readingline - starting line number for source (used by eval)| Method Detail |
|---|
public String getFilename()
public int getLine()
public int getOffset()
public SourcePosition getPosition(SourcePosition startPosition,
boolean inclusive)
public SourcePosition getPosition()
public static LexerSource getSource(String name,
Reader content,
ParserConfiguration configuration)
name - the name of the source (e.g a filename: foo.rb)content - the data of the source
public abstract boolean matchMarker(String marker,
boolean indent,
boolean withNewline)
throws IOException
marker - to match againstindent - eat any leading whitespacewithNewline - includes a check that marker is followed by newline or EOF
IOException - if an error occurred reading from underlying IO source
public abstract int read()
throws IOException
IOException
public abstract String readUntil(char c)
throws IOException
IOException
public abstract String readLineBytes()
throws IOException
IOException
public abstract int skipUntil(int c)
throws IOException
IOExceptionpublic abstract void unread(int c)
public abstract void unreadMany(CharSequence line)
public abstract boolean peek(int c)
throws IOException
IOExceptionpublic abstract boolean lastWasBeginOfLine()
public abstract boolean wasBeginOfLine()
public abstract int chompReadAhead()
public abstract boolean isANewLine()
public abstract void setIsANewLine(boolean nextCharIsOnANewLine)
public abstract void setOffset(int offset)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||