|
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 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavafe.ast._SpecialParserInterface
_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:
DUMMYLOC
and
IDENT
common to both packages, breaking what would
otherwise be a mutual recursion between the two packages. This lets
javafe.ast
be completely independent of
javafe.parser
.
Identifier
class, allowing the scanner to have a
specialized interface to Identifier
without exposing that
interface to more general clients.
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 |
public static final int HC
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.
Constructor Detail |
public _SpecialParserInterface()
Method Detail |
public static int getTokenType(Identifier id)
id
.
The token code will be one that does not require a
non-null auxVal (cf. Token.auxVal).
public static void setTokenType(Identifier id, int tokenType)
id
.
The token code must be one that does not require a
non-null auxVal (cf. Token.auxVal).
public static Identifier intern(char[] text, int textlen, int hashcode)
hashcode = hash(text, textlen)
Ensures: returns the Identifier
instance
associated with the symbol consisting of the first
textlen
characters of text
.
public static int hash(char[] text, int textlen)
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 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |