public abstract class LexerSource extends Object
Modifier and Type | Field and Description |
---|---|
protected ISourcePosition |
lastPosition |
protected int |
line |
protected int |
lineOffset |
protected int |
offset |
Modifier | Constructor and Description |
---|---|
protected |
LexerSource(String sourceName,
List<String> list,
int lineOffset)
Create our food-source for the lexer
|
Modifier and Type | Method and Description |
---|---|
protected void |
captureFeature(int c) |
String |
getCurrentLine() |
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}
Node that this method updates some internal state - it's not just a constructor
|
ISourcePosition |
getPosition(ISourcePosition startPosition)
Where is the reader within the source {filename,row}
Node that this method updates some internal state - it's not just a constructor
|
abstract InputStream |
getRemainingAsStream() |
static LexerSource |
getSource(String name,
byte[] content,
List<String> list,
ParserConfiguration configuration) |
static LexerSource |
getSource(String name,
InputStream content,
List<String> list,
ParserConfiguration configuration)
Create a source.
|
int |
getVirtualLine() |
abstract boolean |
lastWasBeginOfLine() |
protected String |
makePointer(int length) |
abstract boolean |
matchMarker(org.jruby.util.ByteList 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() |
int |
readCodepoint(int first,
org.jcodings.Encoding encoding) |
abstract org.jruby.util.ByteList |
readLineBytes() |
abstract org.jruby.util.ByteList |
readUntil(char c) |
abstract int |
skipUntil(int c) |
void |
startOfToken() |
protected void |
uncaptureFeature(int c) |
abstract void |
unread(int c) |
abstract void |
unreadMany(CharSequence line) |
abstract boolean |
wasBeginOfLine() |
protected int line
protected int lineOffset
protected int offset
protected ISourcePosition lastPosition
public String getFilename()
public int getLine()
public int getVirtualLine()
public int getOffset()
public void startOfToken()
public ISourcePosition getPosition(ISourcePosition startPosition)
public ISourcePosition getPosition()
public static LexerSource getSource(String name, InputStream content, List<String> list, ParserConfiguration configuration)
name
- the name of the source (e.g a filename: foo.rb)content
- the data of the sourcepublic static LexerSource getSource(String name, byte[] content, List<String> list, ParserConfiguration configuration)
protected void captureFeature(int c)
protected void uncaptureFeature(int c)
public String getCurrentLine()
protected String makePointer(int length)
public int readCodepoint(int first, org.jcodings.Encoding encoding) throws IOException
IOException
public abstract boolean matchMarker(org.jruby.util.ByteList 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 EOFIOException
- if an error occurred reading from underlying IO sourcepublic abstract int read() throws IOException
IOException
public abstract org.jruby.util.ByteList readUntil(char c) throws IOException
IOException
public abstract org.jruby.util.ByteList readLineBytes() throws IOException
IOException
public abstract int skipUntil(int c) throws IOException
IOException
public abstract void unread(int c)
public abstract void unreadMany(CharSequence line)
public abstract boolean peek(int c) throws IOException
IOException
public abstract boolean lastWasBeginOfLine()
public abstract boolean wasBeginOfLine()
public abstract InputStream getRemainingAsStream() throws IOException
IOException
Copyright © 2001-2015 JRuby. All Rights Reserved.