org.jruby.lexer.yacc
Class RubyYaccLexer

java.lang.Object
  extended byorg.jruby.lexer.yacc.RubyYaccLexer

public class RubyYaccLexer
extends java.lang.Object

This is a port of the MRI lexer to Java it is compatible to Ruby 1.8.1.


Constructor Summary
RubyYaccLexer()
           
 
Method Summary
 boolean advance()
          How the parser advances to the next token.
 StackState getCmdArgumentState()
           
 StackState getConditionState()
           
 ISourcePosition getPosition()
           
 ISourcePosition getPosition(ISourcePosition startPosition, boolean inclusive)
          Get position information for Token/Node that follows node represented by startPosition and current lexer location.
 ISourcePositionFactory getPositionFactory()
           
 StrTerm getStrTerm()
           
 java.lang.StringBuffer getTokenBuffer()
           
protected  int readComment(char c)
          Read a comment up to end of line.
 void reset()
           
 void resetStacks()
           
 void setParserSupport(ParserSupport parserSupport)
          Parse must pass its support object for some check at bottom of yylex().
 void setSource(LexerSource source)
          Allow the parser to set the source for its lexer.
 void setState(LexState state)
           
 void setStrTerm(StrTerm strterm)
           
 void setValue(java.lang.Object yaccValue)
           
 void setWarnings(IRubyWarnings warnings)
           
 int token()
          Last token read from the lexer at the end of a call to yylex()
 java.lang.Object value()
          Value of last token (if it is a token which has a value).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RubyYaccLexer

public RubyYaccLexer()
Method Detail

reset

public void reset()

advance

public boolean advance()
                throws java.io.IOException
How the parser advances to the next token.

Returns:
true if not at end of file (EOF).
Throws:
java.io.IOException

token

public int token()
Last token read from the lexer at the end of a call to yylex()

Returns:
last token read

getTokenBuffer

public java.lang.StringBuffer getTokenBuffer()

value

public java.lang.Object value()
Value of last token (if it is a token which has a value).

Returns:
value of last value-laden token

getPositionFactory

public ISourcePositionFactory getPositionFactory()

getPosition

public ISourcePosition getPosition(ISourcePosition startPosition,
                                   boolean inclusive)
Get position information for Token/Node that follows node represented by startPosition and current lexer location.

Parameters:
startPosition - previous node/token
inclusive - include previous node into position information of current node
Returns:
a new position

getPosition

public ISourcePosition getPosition()

setParserSupport

public void setParserSupport(ParserSupport parserSupport)
Parse must pass its support object for some check at bottom of yylex(). Ruby does it this way as well (i.e. a little parsing logic in the lexer).

Parameters:
parserSupport -

setSource

public void setSource(LexerSource source)
Allow the parser to set the source for its lexer.

Parameters:
source - where the lexer gets raw data

getStrTerm

public StrTerm getStrTerm()

setStrTerm

public void setStrTerm(StrTerm strterm)

resetStacks

public void resetStacks()

setWarnings

public void setWarnings(IRubyWarnings warnings)

setState

public void setState(LexState state)

getCmdArgumentState

public StackState getCmdArgumentState()

getConditionState

public StackState getConditionState()

setValue

public void setValue(java.lang.Object yaccValue)

readComment

protected int readComment(char c)
                   throws java.io.IOException
Read a comment up to end of line. When found each comment will get stored away into the parser result so that any interested party can use them as they seem fit. One idea is that IDE authors can do distance based heuristics to associate these comments to the AST node they think they belong to.

Parameters:
c - last character read from lexer source
Returns:
newline or eof value
Throws:
java.io.IOException


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