org.mozilla.javascript
Class TokenStream

java.lang.Object
  |
  +--org.mozilla.javascript.TokenStream

public class TokenStream
extends java.lang.Object

This class implements the JavaScript scanner. It is based on the C source files jsscan.c and jsscan.h in the jsref package.

Author:
Mike McCabe, Brendan Eich
See Also:
org.mozilla.javascript.Parser

Field Summary
static int ADD
          Token types.
static int AND
          Token types.
static int ARRAYLIT
          Token types.
static int ASSIGN
          Token types.
static int BINDNAME
          Token types.
static int BITAND
          Token types.
static int BITNOT
          Token types.
static int BITOR
          Token types.
static int BITXOR
          Token types.
static int BLOCK
          Token types.
static int BREAK
          Token types.
static int BREAKPOINT
          Token types.
static int CALL
          Token types.
static int CALLSPECIAL
          Token types.
static int CASE
          Token types.
static int CATCH
          Token types.
static int CLOSURE
          Token types.
static int COLON
          Token types.
static int COMMA
          Token types.
static int CONTINUE
          Token types.
static int CONVERT
          Token types.
static int DEC
          Token types.
static int DEFAULT
          Token types.
static int DELPROP
          Token types.
static int DIV
          Token types.
static int DO
          Token types.
static int DOT
          Token types.
static int DUP
          Token types.
static int ELEMDEC
          Token types.
static int ELEMINC
          Token types.
static int ELSE
          Token types.
static int ENDTRY
          Token types.
static int ENTERWITH
          Token types.
static int ENUMDONE
          Token types.
static int ENUMINIT
          Token types.
static int ENUMNEXT
          Token types.
static int EOF
          Token types.
static int EOL
          Token types.
static int EQ
          Token types.
static int EQOP
          Token types.
static int ERROR
          Token types.
static int EXPORT
          Token types.
static int EXPRSTMT
          Token types.
static int FALSE
          Token types.
static int FINALLY
          Token types.
 int flags
           
static int FOR
          Token types.
static int FUNCTION
          Token types.
static int GE
          Token types.
static int GETBASE
          Token types.
static int GETELEM
          Token types.
static int GETPARENT
          Token types.
static int GETPROP
          Token types.
static int GETPROTO
          Token types.
static int GETSCOPEPARENT
          Token types.
static int GETTHIS
          Token types.
static int GETVAR
          Token types.
static int GOSUB
          Token types.
static int GOTO
          Token types.
static int GT
          Token types.
static int HOOK
          Token types.
static int IF
          Token types.
static int IFEQ
          Token types.
static int IFNE
          Token types.
static int IMPORT
          Token types.
static int IN
          Token types.
static int INC
          Token types.
static int INSTANCEOF
          Token types.
static int INTNUMBER
          Token types.
static int JSR
          Token types.
static int JTHROW
          Token types.
static int LABEL
          Token types.
static int LB
          Token types.
static int LC
          Token types.
static int LE
          Token types.
static int LEAVEWITH
          Token types.
static int LINE
          Token types.
static int LOOP
          Token types.
static int LP
          Token types.
static int LSH
          Token types.
static int LT
          Token types.
static int MOD
          Token types.
static int MUL
          Token types.
static int NAME
          Token types.
static int NAMEDEC
          Token types.
static int NAMEINC
          Token types.
static int NE
          Token types.
static int NEG
          Token types.
static int NEW
          Token types.
static int NEWLOCAL
          Token types.
static int NEWSCOPE
          Token types.
static int NEWTEMP
          Token types.
static int NOP
          Token types.
static int NOT
          Token types.
static int NULL
          Token types.
static int NUMBER
          Token types.
static int OBJECT
          Token types.
static int OBJLIT
          Token types.
static int ONE
          Token types.
static int OR
          Token types.
static int PARENT
          Token types.
static int POP
          Token types.
static int POPV
          Token types.
static int POS
          Token types.
static int POST
          Token types.
static int PRE
          Token types.
static int PRIMARY
          Token types.
static int PROPDEC
          Token types.
static int PROPINC
          Token types.
static int RB
          Token types.
static int RC
          Token types.
 java.lang.String regExpFlags
           
static int RELOP
          Token types.
static int RESERVED
          Token types.
static int RETSUB
          Token types.
static int RETURN
          Token types.
static int RP
          Token types.
static int RSH
          Token types.
static int SCOPE
          Token types.
static int SCRIPT
          Token types.
static int SEMI
          Token types.
static int SETELEM
          Token types.
static int SETNAME
          Token types.
static int SETPARENT
          Token types.
static int SETPROP
          Token types.
static int SETPROTO
          Token types.
static int SETVAR
          Token types.
static int SHEQ
          Token types.
static int SHNE
          Token types.
static int SHOP
          Token types.
static int SHORTNUMBER
          Token types.
static int SOURCEFILE
          Token types.
static int STRING
          Token types.
static int SUB
          Token types.
static int SWITCH
          Token types.
static int TARGET
          Token types.
static int THIS
          Token types.
static int THISFN
          Token types.
static int THROW
          Token types.
static int TRUE
          Token types.
static int TRY
          Token types.
static int TSF_FUNCTION
           
static int TSF_NEWLINES
           
static int TSF_REGEXP
           
static int TSF_RETURN_EXPR
           
static int TSF_RETURN_VOID
           
static int TYPEOF
          Token types.
static int TYPEOFNAME
          Token types.
static int UNARYOP
          Token types.
static int UNDEFINED
          Token types.
static int URSH
          Token types.
static int USELOCAL
          Token types.
static int USETEMP
          Token types.
static int VAR
          Token types.
static int VARDEC
          Token types.
static int VARINC
          Token types.
static int VOID
          Token types.
static int WHILE
          Token types.
static int WITH
          Token types.
static int ZERO
          Token types.
 
Constructor Summary
TokenStream(java.io.Reader in, Scriptable scope, java.lang.String sourceName, int lineno)
           
 
Method Summary
 void clearPushback()
           
 boolean eof()
           
 java.lang.String getLine()
           
 int getLineno()
           
 double getNumber()
           
 int getOffset()
           
 int getOp()
           
 Scriptable getScope()
           
 java.lang.String getSourceName()
           
 java.lang.String getString()
           
 int getToken()
           
 int getTokenno()
           
static boolean isJSLineTerminator(int c)
           
static boolean isJSSpace(int c)
           
 boolean matchToken(int toMatch)
           
 int peekToken()
           
 int peekTokenSameLine()
           
 void reportSyntaxError(java.lang.String messageProperty, java.lang.Object[] args)
           
static java.lang.String tokenToName(int type)
           
 java.lang.String tokenToString(int token)
           
 void ungetToken(int tt)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TSF_NEWLINES

public static final int TSF_NEWLINES

TSF_FUNCTION

public static final int TSF_FUNCTION

TSF_RETURN_EXPR

public static final int TSF_RETURN_EXPR

TSF_RETURN_VOID

public static final int TSF_RETURN_VOID

TSF_REGEXP

public static final int TSF_REGEXP

ERROR

public static final int ERROR
Token types. These values correspond to JSTokenType values in jsscan.c.

EOF

public static final int EOF
Token types. These values correspond to JSTokenType values in jsscan.c.

EOL

public static final int EOL
Token types. These values correspond to JSTokenType values in jsscan.c.

POPV

public static final int POPV
Token types. These values correspond to JSTokenType values in jsscan.c.

ENTERWITH

public static final int ENTERWITH
Token types. These values correspond to JSTokenType values in jsscan.c.

LEAVEWITH

public static final int LEAVEWITH
Token types. These values correspond to JSTokenType values in jsscan.c.

RETURN

public static final int RETURN
Token types. These values correspond to JSTokenType values in jsscan.c.

GOTO

public static final int GOTO
Token types. These values correspond to JSTokenType values in jsscan.c.

IFEQ

public static final int IFEQ
Token types. These values correspond to JSTokenType values in jsscan.c.

IFNE

public static final int IFNE
Token types. These values correspond to JSTokenType values in jsscan.c.

DUP

public static final int DUP
Token types. These values correspond to JSTokenType values in jsscan.c.

SETNAME

public static final int SETNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

BITOR

public static final int BITOR
Token types. These values correspond to JSTokenType values in jsscan.c.

BITXOR

public static final int BITXOR
Token types. These values correspond to JSTokenType values in jsscan.c.

BITAND

public static final int BITAND
Token types. These values correspond to JSTokenType values in jsscan.c.

EQ

public static final int EQ
Token types. These values correspond to JSTokenType values in jsscan.c.

NE

public static final int NE
Token types. These values correspond to JSTokenType values in jsscan.c.

LT

public static final int LT
Token types. These values correspond to JSTokenType values in jsscan.c.

LE

public static final int LE
Token types. These values correspond to JSTokenType values in jsscan.c.

GT

public static final int GT
Token types. These values correspond to JSTokenType values in jsscan.c.

GE

public static final int GE
Token types. These values correspond to JSTokenType values in jsscan.c.

LSH

public static final int LSH
Token types. These values correspond to JSTokenType values in jsscan.c.

RSH

public static final int RSH
Token types. These values correspond to JSTokenType values in jsscan.c.

URSH

public static final int URSH
Token types. These values correspond to JSTokenType values in jsscan.c.

ADD

public static final int ADD
Token types. These values correspond to JSTokenType values in jsscan.c.

SUB

public static final int SUB
Token types. These values correspond to JSTokenType values in jsscan.c.

MUL

public static final int MUL
Token types. These values correspond to JSTokenType values in jsscan.c.

DIV

public static final int DIV
Token types. These values correspond to JSTokenType values in jsscan.c.

MOD

public static final int MOD
Token types. These values correspond to JSTokenType values in jsscan.c.

BITNOT

public static final int BITNOT
Token types. These values correspond to JSTokenType values in jsscan.c.

NEG

public static final int NEG
Token types. These values correspond to JSTokenType values in jsscan.c.

NEW

public static final int NEW
Token types. These values correspond to JSTokenType values in jsscan.c.

DELPROP

public static final int DELPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

TYPEOF

public static final int TYPEOF
Token types. These values correspond to JSTokenType values in jsscan.c.

NAMEINC

public static final int NAMEINC
Token types. These values correspond to JSTokenType values in jsscan.c.

PROPINC

public static final int PROPINC
Token types. These values correspond to JSTokenType values in jsscan.c.

ELEMINC

public static final int ELEMINC
Token types. These values correspond to JSTokenType values in jsscan.c.

NAMEDEC

public static final int NAMEDEC
Token types. These values correspond to JSTokenType values in jsscan.c.

PROPDEC

public static final int PROPDEC
Token types. These values correspond to JSTokenType values in jsscan.c.

ELEMDEC

public static final int ELEMDEC
Token types. These values correspond to JSTokenType values in jsscan.c.

GETPROP

public static final int GETPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

SETPROP

public static final int SETPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

GETELEM

public static final int GETELEM
Token types. These values correspond to JSTokenType values in jsscan.c.

SETELEM

public static final int SETELEM
Token types. These values correspond to JSTokenType values in jsscan.c.

CALL

public static final int CALL
Token types. These values correspond to JSTokenType values in jsscan.c.

NAME

public static final int NAME
Token types. These values correspond to JSTokenType values in jsscan.c.

NUMBER

public static final int NUMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

STRING

public static final int STRING
Token types. These values correspond to JSTokenType values in jsscan.c.

ZERO

public static final int ZERO
Token types. These values correspond to JSTokenType values in jsscan.c.

ONE

public static final int ONE
Token types. These values correspond to JSTokenType values in jsscan.c.

NULL

public static final int NULL
Token types. These values correspond to JSTokenType values in jsscan.c.

THIS

public static final int THIS
Token types. These values correspond to JSTokenType values in jsscan.c.

FALSE

public static final int FALSE
Token types. These values correspond to JSTokenType values in jsscan.c.

TRUE

public static final int TRUE
Token types. These values correspond to JSTokenType values in jsscan.c.

SHEQ

public static final int SHEQ
Token types. These values correspond to JSTokenType values in jsscan.c.

SHNE

public static final int SHNE
Token types. These values correspond to JSTokenType values in jsscan.c.

CLOSURE

public static final int CLOSURE
Token types. These values correspond to JSTokenType values in jsscan.c.

OBJECT

public static final int OBJECT
Token types. These values correspond to JSTokenType values in jsscan.c.

POP

public static final int POP
Token types. These values correspond to JSTokenType values in jsscan.c.

POS

public static final int POS
Token types. These values correspond to JSTokenType values in jsscan.c.

VARINC

public static final int VARINC
Token types. These values correspond to JSTokenType values in jsscan.c.

VARDEC

public static final int VARDEC
Token types. These values correspond to JSTokenType values in jsscan.c.

BINDNAME

public static final int BINDNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

THROW

public static final int THROW
Token types. These values correspond to JSTokenType values in jsscan.c.

IN

public static final int IN
Token types. These values correspond to JSTokenType values in jsscan.c.

INSTANCEOF

public static final int INSTANCEOF
Token types. These values correspond to JSTokenType values in jsscan.c.

GOSUB

public static final int GOSUB
Token types. These values correspond to JSTokenType values in jsscan.c.

RETSUB

public static final int RETSUB
Token types. These values correspond to JSTokenType values in jsscan.c.

CALLSPECIAL

public static final int CALLSPECIAL
Token types. These values correspond to JSTokenType values in jsscan.c.

GETTHIS

public static final int GETTHIS
Token types. These values correspond to JSTokenType values in jsscan.c.

NEWTEMP

public static final int NEWTEMP
Token types. These values correspond to JSTokenType values in jsscan.c.

USETEMP

public static final int USETEMP
Token types. These values correspond to JSTokenType values in jsscan.c.

GETBASE

public static final int GETBASE
Token types. These values correspond to JSTokenType values in jsscan.c.

GETVAR

public static final int GETVAR
Token types. These values correspond to JSTokenType values in jsscan.c.

SETVAR

public static final int SETVAR
Token types. These values correspond to JSTokenType values in jsscan.c.

UNDEFINED

public static final int UNDEFINED
Token types. These values correspond to JSTokenType values in jsscan.c.

TRY

public static final int TRY
Token types. These values correspond to JSTokenType values in jsscan.c.

ENDTRY

public static final int ENDTRY
Token types. These values correspond to JSTokenType values in jsscan.c.

NEWSCOPE

public static final int NEWSCOPE
Token types. These values correspond to JSTokenType values in jsscan.c.

TYPEOFNAME

public static final int TYPEOFNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

ENUMINIT

public static final int ENUMINIT
Token types. These values correspond to JSTokenType values in jsscan.c.

ENUMNEXT

public static final int ENUMNEXT
Token types. These values correspond to JSTokenType values in jsscan.c.

GETPROTO

public static final int GETPROTO
Token types. These values correspond to JSTokenType values in jsscan.c.

GETPARENT

public static final int GETPARENT
Token types. These values correspond to JSTokenType values in jsscan.c.

SETPROTO

public static final int SETPROTO
Token types. These values correspond to JSTokenType values in jsscan.c.

SETPARENT

public static final int SETPARENT
Token types. These values correspond to JSTokenType values in jsscan.c.

SCOPE

public static final int SCOPE
Token types. These values correspond to JSTokenType values in jsscan.c.

GETSCOPEPARENT

public static final int GETSCOPEPARENT
Token types. These values correspond to JSTokenType values in jsscan.c.

THISFN

public static final int THISFN
Token types. These values correspond to JSTokenType values in jsscan.c.

JTHROW

public static final int JTHROW
Token types. These values correspond to JSTokenType values in jsscan.c.

SEMI

public static final int SEMI
Token types. These values correspond to JSTokenType values in jsscan.c.

LB

public static final int LB
Token types. These values correspond to JSTokenType values in jsscan.c.

RB

public static final int RB
Token types. These values correspond to JSTokenType values in jsscan.c.

LC

public static final int LC
Token types. These values correspond to JSTokenType values in jsscan.c.

RC

public static final int RC
Token types. These values correspond to JSTokenType values in jsscan.c.

LP

public static final int LP
Token types. These values correspond to JSTokenType values in jsscan.c.

RP

public static final int RP
Token types. These values correspond to JSTokenType values in jsscan.c.

COMMA

public static final int COMMA
Token types. These values correspond to JSTokenType values in jsscan.c.

ASSIGN

public static final int ASSIGN
Token types. These values correspond to JSTokenType values in jsscan.c.

HOOK

public static final int HOOK
Token types. These values correspond to JSTokenType values in jsscan.c.

COLON

public static final int COLON
Token types. These values correspond to JSTokenType values in jsscan.c.

OR

public static final int OR
Token types. These values correspond to JSTokenType values in jsscan.c.

AND

public static final int AND
Token types. These values correspond to JSTokenType values in jsscan.c.

EQOP

public static final int EQOP
Token types. These values correspond to JSTokenType values in jsscan.c.

RELOP

public static final int RELOP
Token types. These values correspond to JSTokenType values in jsscan.c.

SHOP

public static final int SHOP
Token types. These values correspond to JSTokenType values in jsscan.c.

UNARYOP

public static final int UNARYOP
Token types. These values correspond to JSTokenType values in jsscan.c.

INC

public static final int INC
Token types. These values correspond to JSTokenType values in jsscan.c.

DEC

public static final int DEC
Token types. These values correspond to JSTokenType values in jsscan.c.

DOT

public static final int DOT
Token types. These values correspond to JSTokenType values in jsscan.c.

PRIMARY

public static final int PRIMARY
Token types. These values correspond to JSTokenType values in jsscan.c.

FUNCTION

public static final int FUNCTION
Token types. These values correspond to JSTokenType values in jsscan.c.

EXPORT

public static final int EXPORT
Token types. These values correspond to JSTokenType values in jsscan.c.

IMPORT

public static final int IMPORT
Token types. These values correspond to JSTokenType values in jsscan.c.

IF

public static final int IF
Token types. These values correspond to JSTokenType values in jsscan.c.

ELSE

public static final int ELSE
Token types. These values correspond to JSTokenType values in jsscan.c.

SWITCH

public static final int SWITCH
Token types. These values correspond to JSTokenType values in jsscan.c.

CASE

public static final int CASE
Token types. These values correspond to JSTokenType values in jsscan.c.

DEFAULT

public static final int DEFAULT
Token types. These values correspond to JSTokenType values in jsscan.c.

WHILE

public static final int WHILE
Token types. These values correspond to JSTokenType values in jsscan.c.

DO

public static final int DO
Token types. These values correspond to JSTokenType values in jsscan.c.

FOR

public static final int FOR
Token types. These values correspond to JSTokenType values in jsscan.c.

BREAK

public static final int BREAK
Token types. These values correspond to JSTokenType values in jsscan.c.

CONTINUE

public static final int CONTINUE
Token types. These values correspond to JSTokenType values in jsscan.c.

VAR

public static final int VAR
Token types. These values correspond to JSTokenType values in jsscan.c.

WITH

public static final int WITH
Token types. These values correspond to JSTokenType values in jsscan.c.

CATCH

public static final int CATCH
Token types. These values correspond to JSTokenType values in jsscan.c.

FINALLY

public static final int FINALLY
Token types. These values correspond to JSTokenType values in jsscan.c.

RESERVED

public static final int RESERVED
Token types. These values correspond to JSTokenType values in jsscan.c.

NOP

public static final int NOP
Token types. These values correspond to JSTokenType values in jsscan.c.

NOT

public static final int NOT
Token types. These values correspond to JSTokenType values in jsscan.c.

PRE

public static final int PRE
Token types. These values correspond to JSTokenType values in jsscan.c.

POST

public static final int POST
Token types. These values correspond to JSTokenType values in jsscan.c.

VOID

public static final int VOID
Token types. These values correspond to JSTokenType values in jsscan.c.

BLOCK

public static final int BLOCK
Token types. These values correspond to JSTokenType values in jsscan.c.

ARRAYLIT

public static final int ARRAYLIT
Token types. These values correspond to JSTokenType values in jsscan.c.

OBJLIT

public static final int OBJLIT
Token types. These values correspond to JSTokenType values in jsscan.c.

LABEL

public static final int LABEL
Token types. These values correspond to JSTokenType values in jsscan.c.

TARGET

public static final int TARGET
Token types. These values correspond to JSTokenType values in jsscan.c.

LOOP

public static final int LOOP
Token types. These values correspond to JSTokenType values in jsscan.c.

ENUMDONE

public static final int ENUMDONE
Token types. These values correspond to JSTokenType values in jsscan.c.

EXPRSTMT

public static final int EXPRSTMT
Token types. These values correspond to JSTokenType values in jsscan.c.

PARENT

public static final int PARENT
Token types. These values correspond to JSTokenType values in jsscan.c.

CONVERT

public static final int CONVERT
Token types. These values correspond to JSTokenType values in jsscan.c.

JSR

public static final int JSR
Token types. These values correspond to JSTokenType values in jsscan.c.

NEWLOCAL

public static final int NEWLOCAL
Token types. These values correspond to JSTokenType values in jsscan.c.

USELOCAL

public static final int USELOCAL
Token types. These values correspond to JSTokenType values in jsscan.c.

SCRIPT

public static final int SCRIPT
Token types. These values correspond to JSTokenType values in jsscan.c.

LINE

public static final int LINE
Token types. These values correspond to JSTokenType values in jsscan.c.

SOURCEFILE

public static final int SOURCEFILE
Token types. These values correspond to JSTokenType values in jsscan.c.

BREAKPOINT

public static final int BREAKPOINT
Token types. These values correspond to JSTokenType values in jsscan.c.

SHORTNUMBER

public static final int SHORTNUMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

INTNUMBER

public static final int INTNUMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

flags

public int flags

regExpFlags

public java.lang.String regExpFlags
Constructor Detail

TokenStream

public TokenStream(java.io.Reader in,
                   Scriptable scope,
                   java.lang.String sourceName,
                   int lineno)
Method Detail

tokenToString

public java.lang.String tokenToString(int token)

tokenToName

public static java.lang.String tokenToName(int type)

getScope

public Scriptable getScope()

matchToken

public boolean matchToken(int toMatch)
                   throws java.io.IOException

clearPushback

public void clearPushback()

ungetToken

public void ungetToken(int tt)

peekToken

public int peekToken()
              throws java.io.IOException

peekTokenSameLine

public int peekTokenSameLine()
                      throws java.io.IOException

isJSSpace

public static boolean isJSSpace(int c)

isJSLineTerminator

public static boolean isJSLineTerminator(int c)

getToken

public int getToken()
             throws java.io.IOException

reportSyntaxError

public void reportSyntaxError(java.lang.String messageProperty,
                              java.lang.Object[] args)

getSourceName

public java.lang.String getSourceName()

getLineno

public int getLineno()

getOp

public int getOp()

getString

public java.lang.String getString()

getNumber

public double getNumber()

getLine

public java.lang.String getLine()

getOffset

public int getOffset()

getTokenno

public int getTokenno()

eof

public boolean eof()