org.jruby.lexer.yacc
Class InputStreamLexerSource

java.lang.Object
  extended by org.jruby.lexer.yacc.LexerSource
      extended by org.jruby.lexer.yacc.InputStreamLexerSource

public class InputStreamLexerSource
extends LexerSource


Field Summary
 
Fields inherited from class org.jruby.lexer.yacc.LexerSource
line, offset
 
Constructor Summary
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
 
Method Summary
static LexerSource getSource(java.lang.String name, java.io.InputStream content, java.util.List<java.lang.String> list, ParserConfiguration configuration)
          Create a source.
 boolean lastWasBeginOfLine()
           
 boolean matchMarker(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
 ByteList readLineBytes()
           
 ByteList readUntil(char marker)
           
 int skipUntil(int c)
           
 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
 
Methods inherited from class org.jruby.lexer.yacc.LexerSource
captureFeature, getFilename, getLine, getOffset, getPosition, getPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InputStreamLexerSource

public 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

Parameters:
sourceName - is the file we are reading
reader - is what represents the contents of file sourceName
line - starting line number for source (used by eval)
extraPositionInformation - will gives us extra information that an IDE may want
Method Detail

read

public int read()
         throws java.io.IOException
Read next character from this source

Specified by:
read in class LexerSource
Returns:
next character to viewed by the source
Throws:
java.io.IOException

unread

public void unread(int c)
Pushes char back onto this source. Note, this also allows us to push whatever is passes back into the source.

Specified by:
unread in class LexerSource
Parameters:
to - be put back onto the source

peek

public boolean peek(int to)
             throws java.io.IOException
Is the next character equal to 'to'

Specified by:
peek in class LexerSource
Parameters:
to - character to compare against
Returns:
true if the same
Throws:
java.io.IOException

getSource

public static LexerSource getSource(java.lang.String name,
                                    java.io.InputStream content,
                                    java.util.List<java.lang.String> list,
                                    ParserConfiguration configuration)
Create a source.

Parameters:
name - the name of the source (e.g a filename: foo.rb)
content - the data of the source
Returns:
the new source

readLineBytes

public ByteList readLineBytes()
                       throws java.io.IOException
Specified by:
readLineBytes in class LexerSource
Throws:
java.io.IOException

skipUntil

public int skipUntil(int c)
              throws java.io.IOException
Specified by:
skipUntil in class LexerSource
Throws:
java.io.IOException

unreadMany

public void unreadMany(java.lang.CharSequence buffer)
Specified by:
unreadMany in class LexerSource

matchMarker

public boolean matchMarker(ByteList match,
                           boolean indent,
                           boolean checkNewline)
                    throws java.io.IOException
Description copied from class: LexerSource
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.

Specified by:
matchMarker in class LexerSource
Parameters:
match - to match against
indent - eat any leading whitespace
checkNewline - includes a check that marker is followed by newline or EOF
Returns:
true if marker matches...false otherwise
Throws:
java.io.IOException - if an error occurred reading from underlying IO source

wasBeginOfLine

public boolean wasBeginOfLine()
Was the last character read from the stream the first character on a line

Specified by:
wasBeginOfLine in class LexerSource
Returns:
true if so

lastWasBeginOfLine

public boolean lastWasBeginOfLine()
Specified by:
lastWasBeginOfLine in class LexerSource

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readUntil

public ByteList readUntil(char marker)
                   throws java.io.IOException
Specified by:
readUntil in class LexerSource
Throws:
java.io.IOException


Copyright © 2002-2007 JRuby Team. All Rights Reserved.