com.go.tea.compiler
Class Scanner

java.lang.Object
  |
  +--com.go.tea.compiler.Scanner

public class Scanner
extends java.lang.Object

A Scanner breaks up a source file into its basic elements, called Tokens. Add an ErrorListener to capture any syntax errors detected by the Scanner.

Version:
45 , 00/12/13
Author:
Brian S O'Neill

Constructor Summary
Scanner(SourceReader in)
           
Scanner(SourceReader in, CompilationUnit unit)
           
 
Method Summary
 void addErrorListener(ErrorListener listener)
           
 void close()
           
 void emitSpecialTokens(boolean enable)
          Passing true causes Scanner to emit additional tokens that should not be bassed into a Parser.
 int getErrorCount()
           
static void main(java.lang.String[] arg)
          Simple test program
 Token peekToken()
          Returns EOF as the last token.
 Token readToken()
          Returns EOF as the last token.
 void removeErrorListener(ErrorListener listener)
           
 void unreadToken(Token token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(SourceReader in)

Scanner

public Scanner(SourceReader in,
               CompilationUnit unit)
Method Detail

addErrorListener

public void addErrorListener(ErrorListener listener)

removeErrorListener

public void removeErrorListener(ErrorListener listener)

emitSpecialTokens

public void emitSpecialTokens(boolean enable)
Passing true causes Scanner to emit additional tokens that should not be bassed into a Parser. These are Token.COMMENT, Token.ENTER_CODE, and Token.ENTER_TEXT. By default, these special tokens are not emitted.

readToken

public Token readToken()
                throws java.io.IOException
Returns EOF as the last token.

peekToken

public Token peekToken()
                throws java.io.IOException
Returns EOF as the last token.

unreadToken

public void unreadToken(Token token)
                 throws java.io.IOException

close

public void close()
           throws java.io.IOException

getErrorCount

public int getErrorCount()

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
Simple test program