public class InputStreamLexerSource extends LexerSource
| Modifier and Type | Field and Description |
|---|---|
private char[] |
buf |
private int |
bufLength |
static int |
DATA_READ_BUFFER_SIZE |
(package private) static org.jruby.util.ByteList |
EOF_LABEL |
private java.io.InputStream |
in |
private static int |
INITIAL_PUSHBACK_SIZE |
private int |
oneAgo |
private int |
twoAgo |
line, lineOffset, offset| Constructor and Description |
|---|
InputStreamLexerSource(java.lang.String sourceName,
java.io.InputStream in,
java.util.List<java.lang.String> list,
int line,
boolean extraPositionInformation)
Create our food-source for the lexer
|
| Modifier and Type | Method and Description |
|---|---|
private void |
advance(int c) |
private int |
carriageReturn(int c) |
private boolean |
finishMarker(boolean checkNewline,
org.jruby.util.ByteList buffer) |
java.io.InputStream |
getRemainingAsStream() |
private void |
growBuf() |
private void |
indentLoop(org.jruby.util.ByteList buffer) |
boolean |
lastWasBeginOfLine() |
private boolean |
matches(org.jruby.util.ByteList match,
org.jruby.util.ByteList buffer,
int length) |
boolean |
matchMarker(org.jruby.util.ByteList match,
boolean indent,
boolean checkNewline)
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.
|
boolean |
peek(int to)
Is the next character equal to 'to'
|
int |
read()
Read next character from this source
|
org.jruby.util.ByteList |
readLineBytes() |
org.jruby.util.ByteList |
readUntil(char marker) |
private void |
retreat() |
int |
skipUntil(int marker) |
java.lang.String |
toString() |
void |
unread(int c)
Pushes char back onto this source.
|
void |
unreadMany(java.lang.CharSequence buffer) |
boolean |
wasBeginOfLine()
Was the last character read from the stream the first character on a line
|
private int |
wrappedRead()
Convenience method to hide exception.
|
captureFeature, getCurrentLine, getFilename, getLine, getOffset, getPosition, getPosition, getSource, getSource, getVirtualLine, makePointer, readCodepoint, uncaptureFeatureprivate static final int INITIAL_PUSHBACK_SIZE
public static final int DATA_READ_BUFFER_SIZE
private final java.io.InputStream in
private char[] buf
private int bufLength
private int oneAgo
private int twoAgo
static final org.jruby.util.ByteList EOF_LABEL
public InputStreamLexerSource(java.lang.String sourceName,
java.io.InputStream in,
java.util.List<java.lang.String> list,
int line,
boolean extraPositionInformation)
sourceName - is the file we are readingreader - is what represents the contents of file sourceNameline - starting line number for source (used by eval)extraPositionInformation - will gives us extra information that an IDE may wantpublic int read()
throws java.io.IOException
read in class LexerSourcejava.io.IOExceptionpublic void unread(int c)
unread in class LexerSourceto - be put back onto the sourcepublic boolean peek(int to)
throws java.io.IOException
peek in class LexerSourceto - character to compare againstjava.io.IOExceptionprivate void advance(int c)
private int carriageReturn(int c)
throws java.io.IOException
java.io.IOExceptionprivate void growBuf()
private void retreat()
private int wrappedRead()
throws java.io.IOException
java.io.IOExceptionpublic org.jruby.util.ByteList readLineBytes()
throws java.io.IOException
readLineBytes in class LexerSourcejava.io.IOExceptionpublic int skipUntil(int marker)
throws java.io.IOException
skipUntil in class LexerSourcejava.io.IOExceptionpublic void unreadMany(java.lang.CharSequence buffer)
unreadMany in class LexerSourcepublic boolean matchMarker(org.jruby.util.ByteList match,
boolean indent,
boolean checkNewline)
throws java.io.IOException
LexerSourcematchMarker in class LexerSourcematch - to match againstindent - eat any leading whitespacecheckNewline - includes a check that marker is followed by newline or EOFjava.io.IOException - if an error occurred reading from underlying IO sourceprivate void indentLoop(org.jruby.util.ByteList buffer)
throws java.io.IOException
java.io.IOExceptionprivate boolean matches(org.jruby.util.ByteList match,
org.jruby.util.ByteList buffer,
int length)
throws java.io.IOException
java.io.IOExceptionprivate boolean finishMarker(boolean checkNewline,
org.jruby.util.ByteList buffer)
throws java.io.IOException
java.io.IOExceptionpublic boolean wasBeginOfLine()
wasBeginOfLine in class LexerSourcepublic boolean lastWasBeginOfLine()
lastWasBeginOfLine in class LexerSourcepublic java.lang.String toString()
toString in class java.lang.Objectpublic org.jruby.util.ByteList readUntil(char marker)
throws java.io.IOException
readUntil in class LexerSourcejava.io.IOExceptionpublic java.io.InputStream getRemainingAsStream()
throws java.io.IOException
getRemainingAsStream in class LexerSourcejava.io.IOException