at.dms.compiler.tools.antlr.extra
Class Scanner

java.lang.Object
  extended by at.dms.compiler.tools.antlr.extra.Scanner
All Implemented Interfaces:
TokenStream

public abstract class Scanner
extends Object
implements TokenStream

This class describes the capabilities of lexers (token streams) to share a common input buffer and to handle line numbers.


Field Summary
static CToken TOKEN_EOF
           
 
Constructor Summary
protected Scanner(Compiler compiler, InputBuffer buffer)
          Constructs a new hand written scanner
 
Method Summary
 void addComment(JavaStyleComment comment)
           
 InputBuffer getBuffer()
          Returns the input buffer.
abstract  InputBufferState getBufferState()
          Returns the buffer state.
 JavadocComment getJavadocComment()
           
 int getLine()
          Returns the current line number in the source code.
 JavaStyleComment[] getStatementComment()
           
 TokenReference getTokenReference()
          Returns the reference of the current token in the source file.
 void incrementLine()
          Sets the current line number in the source code.
 Token nextToken()
          Returns the next token in the input.
abstract  Token nextTokenImpl()
          Returns the next token in the input.
protected  void reportTrouble(MessageDescription mess, Object[] params)
          Reports that an error has been detected in the lexical analyser.
protected  void reportTrouble(PositionedError trouble)
          Reports that an error has been detected in the lexical analyser.
 void setFile(String file)
           
 void setLine(int line)
          Sets the current line number in the source code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOKEN_EOF

public static final CToken TOKEN_EOF
Constructor Detail

Scanner

protected Scanner(Compiler compiler,
                  InputBuffer buffer)
Constructs a new hand written scanner

Method Detail

nextToken

public final Token nextToken()
Returns the next token in the input.

Specified by:
nextToken in interface TokenStream

nextTokenImpl

public abstract Token nextTokenImpl()
                             throws IOException
Returns the next token in the input.

Throws:
IOException

getTokenReference

public final TokenReference getTokenReference()
Returns the reference of the current token in the source file.


reportTrouble

protected final void reportTrouble(PositionedError trouble)
Reports that an error has been detected in the lexical analyser. The handling is delegated to the compiler driver.

Parameters:
trouble - the error to report

reportTrouble

protected final void reportTrouble(MessageDescription mess,
                                   Object[] params)
Reports that an error has been detected in the lexical analyser. The handling is delegated to the compiler driver.

Parameters:
mess - the error message
params - the array of message parameters

addComment

public final void addComment(JavaStyleComment comment)

getStatementComment

public JavaStyleComment[] getStatementComment()

getJavadocComment

public JavadocComment getJavadocComment()

getBuffer

public final InputBuffer getBuffer()
Returns the input buffer.


setFile

public void setFile(String file)

getLine

public final int getLine()
Returns the current line number in the source code.


setLine

public final void setLine(int line)
Sets the current line number in the source code.


incrementLine

public final void incrementLine()
Sets the current line number in the source code.


getBufferState

public abstract InputBufferState getBufferState()
Returns the buffer state.