ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

javafe.ast
Class _SpecialParserInterface

java.lang.Object
  extended byjavafe.ast._SpecialParserInterface

public abstract class _SpecialParserInterface
extends java.lang.Object

_SpecialParserInterface is not a class that should be used by general clients of the javafe.ast package. It holds a number of routines and constants used by the javafe.parser package that we want to hide from other, more general clients of javafe.ast. _SpecialParserInterface serves two purposes:

The "friend" interface to Identifier exposed by _SpecialParserInterface includes a extra integer field of Identifier objects used to hold token types. For most instances of Identifier, this hidden field holds the value IDENT, the token code for identifiers. However, for an Identifier object associated with a keyword, the hidden field holds the token type for the keyword. During its initialization, the scanner class interns all keywords and uses the _SpecialParserInterface.setTokenType to write the appropriate token-type values into the hidden fields of the resulting Identifier objects. Note that no synchronization is done by _SpecialParserInterface when reading and writing these fields.


Field Summary
static int HC
          Constant used for hashing.
 
Constructor Summary
_SpecialParserInterface()
           
 
Method Summary
static int getTokenType(Identifier id)
          Return the hidden "token type" field of id.
static int hash(char[] text, int textlen)
          Return the hash code used by Identifier for a given sequence of characters.
static Identifier intern(char[] text, int textlen, int hashcode)
          Intern a sequence of characters with a pre-computed hashcode.
static void setTokenType(Identifier id, int tokenType)
          Set the hidden "token type" field of id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HC

public static final int HC
Constant used for hashing. The hash function used to hash a n-character identifier idn is to sum HC^(n-(i+1))*idn[i]. Note that this is the same hash function used by Java 1.1 for hashing String objects.

See Also:
Constant Field Values
Constructor Detail

_SpecialParserInterface

public _SpecialParserInterface()
Method Detail

getTokenType

public static int getTokenType(Identifier id)
Return the hidden "token type" field of id. The token code will be one that does not require a non-null auxVal (cf. Token.auxVal).


setTokenType

public static void setTokenType(Identifier id,
                                int tokenType)
Set the hidden "token type" field of id. The token code must be one that does not require a non-null auxVal (cf. Token.auxVal).


intern

public static Identifier intern(char[] text,
                                int textlen,
                                int hashcode)
Intern a sequence of characters with a pre-computed hashcode.
Requires: hashcode = hash(text, textlen)

Ensures: returns the Identifier instance associated with the symbol consisting of the first textlen characters of text.


hash

public static int hash(char[] text,
                       int textlen)
Return the hash code used by Identifier for a given sequence of characters.


ESC/Java2
© 2003,2004,2005 David Cok and Joseph Kiniry
© 2005 UCD Dublin
© 2003,2004 Radboud University Nijmegen
© 1999,2000 Compaq Computer Corporation
© 1997,1998,1999 Digital Equipment Corporation
All Rights Reserved

The ESC/Java2 Project Homepage