Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

alice.tuprolog
Class Tokenizer  view Tokenizer download Tokenizer.java

java.lang.Object
  extended byalice.tuprolog.Tokenizer
All Implemented Interfaces:
java.io.Serializable

class Tokenizer
extends java.lang.Object
implements java.io.Serializable

tokenizer for prolog terms


Field Summary
static int ATOM
           
static int ATTRMASK
           
static int BAR
           
private  alice.util.LinkedList charList
          where to store unread characters
static int COMMA
           
static int DQ_SEQUENCE
           
static int END
           
static int EOF
           
static int ERROR
           
static int FLOAT
           
static int FUNCTOR
           
private  alice.util.StringInputStream inputStream
          string input stream source of text to be parsed
static int INTEGER
           
(package private)  int lastTokenType
          last token type
static int LBRA
           
static int LBRA2
           
static int LPAR
           
static int OPERATOR
           
static int RBRA
           
static int RBRA2
           
static int RPAR
           
private  java.lang.String seq
          current token text
static int SQ_SEQUENCE
           
static java.lang.String SYMCHAR
           
private  alice.util.LinkedList tokenList
          where to store unread tokens
private  int type
          current token type
static int TYPEMASK
           
static int VARIABLE
           
 
Constructor Summary
Tokenizer(alice.util.StringInputStream is)
          creating a tokenizer for the source stream
 
Method Summary
 int getCurrentLine()
          gets current line index on the stream
 int getCurrentPos()
          gets current character index on the stream
static boolean isAtom(java.lang.String s)
          is the string a prolog atom?
private static boolean isCmt(int c)
           
private static boolean isDgt(int c)
           
private static boolean isExp(int c)
           
private static boolean isLLt(int c)
           
private static boolean isLtr(int c)
           
private  boolean isNum(int c)
           
private static boolean isSym(int c)
           
private static boolean isTer(int c)
           
private static boolean isULt(int c)
           
private static boolean isWht(int c)
           
private  int nextToken()
           
private  int readChar()
           
 Token readToken()
          reads next available token
 void reset()
          resets parsing process.
private  int skip()
           
private  void unreadChar(int ch)
           
 void unreadToken(Token token)
          puts back token to be read again
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPEMASK

public static final int TYPEMASK
See Also:
Constant Field Values

ATTRMASK

public static final int ATTRMASK
See Also:
Constant Field Values

LPAR

public static final int LPAR
See Also:
Constant Field Values

RPAR

public static final int RPAR
See Also:
Constant Field Values

LBRA

public static final int LBRA
See Also:
Constant Field Values

RBRA

public static final int RBRA
See Also:
Constant Field Values

BAR

public static final int BAR
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

ATOM

public static final int ATOM
See Also:
Constant Field Values

VARIABLE

public static final int VARIABLE
See Also:
Constant Field Values

SQ_SEQUENCE

public static final int SQ_SEQUENCE
See Also:
Constant Field Values

DQ_SEQUENCE

public static final int DQ_SEQUENCE
See Also:
Constant Field Values

COMMA

public static final int COMMA
See Also:
Constant Field Values

END

public static final int END
See Also:
Constant Field Values

LBRA2

public static final int LBRA2
See Also:
Constant Field Values

RBRA2

public static final int RBRA2
See Also:
Constant Field Values

FUNCTOR

public static final int FUNCTOR
See Also:
Constant Field Values

OPERATOR

public static final int OPERATOR
See Also:
Constant Field Values

EOF

public static final int EOF
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

SYMCHAR

public static final java.lang.String SYMCHAR
See Also:
Constant Field Values

inputStream

private alice.util.StringInputStream inputStream
string input stream source of text to be parsed


charList

private alice.util.LinkedList charList
where to store unread characters


tokenList

private alice.util.LinkedList tokenList
where to store unread tokens


type

private int type
current token type


seq

private java.lang.String seq
current token text


lastTokenType

int lastTokenType
last token type

Constructor Detail

Tokenizer

public Tokenizer(alice.util.StringInputStream is)
creating a tokenizer for the source stream

Method Detail

readToken

public Token readToken()
reads next available token


unreadToken

public void unreadToken(Token token)
puts back token to be read again


getCurrentPos

public int getCurrentPos()
gets current character index on the stream


getCurrentLine

public int getCurrentLine()
gets current line index on the stream


reset

public void reset()
           throws java.lang.Exception
resets parsing process.

it's ready to parse from the beginning of the source


isAtom

public static boolean isAtom(java.lang.String s)
is the string a prolog atom?


isTer

private static boolean isTer(int c)

isWht

private static boolean isWht(int c)

isCmt

private static boolean isCmt(int c)

isDgt

private static boolean isDgt(int c)

isLLt

private static boolean isLLt(int c)

isULt

private static boolean isULt(int c)

isLtr

private static boolean isLtr(int c)

isExp

private static boolean isExp(int c)

isSym

private static boolean isSym(int c)

isNum

private boolean isNum(int c)

readChar

private int readChar()

unreadChar

private void unreadChar(int ch)

skip

private int skip()

nextToken

private int nextToken()