|
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.parser.ParseUtil
javafe.parser.ParseType
javafe.parser.ParseExpr
Parses java expressions. Extended by ParseStmt
.
ASTNode
,
ParseType
,
ParseStmt
Field Summary | |
private int |
defaultStackSize
|
private Expr[] |
exprStack
|
private boolean[] |
isLeftAssocTable
|
private int[] |
locStack
|
private int[] |
opStack
|
private int[] |
precedenceStack
|
private int[] |
precedenceTable
|
protected StackVector |
seqExpr
Internal working storage for parseNewExpression, parseExpressionList, and ParseStmt.parseForStmt functions. |
protected StackVector |
seqTypeDeclElem
Internal working storage for parseNewExpression function. |
protected StackVector |
seqVarInit
Internal working storage for parseArrayInitializer function. |
private int |
stackPtr
|
Fields inherited from class javafe.parser.ParseType |
seqIdentifier |
Fields inherited from class javafe.parser.ParseUtil |
modifierKeywords, modifierPragmas, seqModifierPragma |
Constructor Summary | |
ParseExpr()
|
Method Summary | |
(package private) abstract void |
addDefaultConstructor(TypeDeclElemVec elems,
int loc,
boolean specOnly)
If no constructors are found in "elems", adds a default one to it. |
void |
addOperator(int ttype,
int precedence,
boolean isLeftAssoc)
Add an infix, binary operator to the parser with a given precedence and associativity. |
boolean |
isStartOfUnaryExpressionNotPlusMinus(int tag)
Determines whether the tag is the first token of a UnaryExpressionNotPlusMinus. |
ExprVec |
parseArgumentList(Lex l)
Parse an ArgumentList, which includes enclosing parens. |
ArrayInit |
parseArrayInitializer(Lex l)
|
Expr |
parseCastExpression(Lex l)
Parse a CastExpression. |
protected Expr |
parseClassLiteralSuffix(Lex l,
Type t)
parses '. class', then produces a class literal expression using Type t. |
Expr |
parseExpression(Lex l)
Parse an Expression. |
ExprVec |
parseExpressionList(Lex l,
int terminator)
Parse an ExpressionList. |
Expr |
parseNewExpression(Lex l)
Parse a NewExpression. |
Expr |
parseNewExpressionTail(Lex l,
Type type,
int locNew)
|
protected Expr |
parsePrimaryExpression(Lex l)
Parse a PrimaryExpression. |
protected Expr |
parsePrimarySuffix(Lex l,
Expr primary)
|
Name |
parseSuper(Lex l)
Parse super. |
(package private) abstract TypeDeclElem |
parseTypeDeclElemIntoSeqTDE(Lex l,
int keyword,
Identifier containerId,
boolean specOnly)
Parse an element of a type declaration into "seq". |
Expr |
parseUnaryExpression(Lex l)
Parse a UnaryExpression. |
VarInit |
parseVariableInitializer(Lex l,
boolean specOnly)
Parse VariableInitializer. |
Methods inherited from class javafe.parser.ParseType |
isPrimitiveKeywordTag, parseBracketPairs, parseIdentifier, parseName, parsePrimitiveType, parsePrimitiveTypeOrTypeName, parseType, parseTypeModifierPragmas, parseTypeName |
Methods inherited from class javafe.parser.ParseUtil |
arrayToString, error, expect, fail, getJavaModifier, isJavaModifier, operatorTokenToTag, parseModifierPragmas, parseModifiers, parseMoreModifierPragmas |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private int defaultStackSize
private int stackPtr
private Expr[] exprStack
private int[] opStack
private int[] precedenceStack
private int[] locStack
private int[] precedenceTable
private boolean[] isLeftAssocTable
protected final StackVector seqExpr
protected final StackVector seqVarInit
protected final StackVector seqTypeDeclElem
Constructor Detail |
public ParseExpr()
Method Detail |
abstract void addDefaultConstructor(TypeDeclElemVec elems, int loc, boolean specOnly)
abstract TypeDeclElem parseTypeDeclElemIntoSeqTDE(Lex l, int keyword, Identifier containerId, boolean specOnly)
public void addOperator(int ttype, int precedence, boolean isLeftAssoc)
Operator | Precedenc | Assoc |
TagConstants.STAR | 170 | left |
TagConstants.DIV | 170 | left |
TagConstants.MOD | 170 | left |
TagConstants.ADD | 160 | left |
TagConstants.SUB | 160 | left |
TagConstants.LSHIFT | 150 | left |
TagConstants.RSHIFT | 150 | left |
TagConstants.URSHIFT | 150 | left |
TagConstants.GE | 140 | left |
TagConstants.GT | 140 | left |
TagConstants.LT | 140 | left |
TagConstants.LE | 140 | left |
TagConstants.INSTANCEOF | 140 | left |
TagConstants.EQ | 130 | left |
TagConstants.NE | 130 | left |
TagConstants.BITAND | 120 | left |
TagConstants.BITXOR | 110 | left |
TagConstants.BITOR | 100 | left |
TagConstants.AND | 90 | left |
TagConstants.OR | 80 | left |
TagConstants.QUESTIONMARK | 70 | left |
TagConstants.ASSIGN | 60 | right |
TagConstants.ASGMUL | 60 | right |
TagConstants.ASGDIV | 60 | right |
TagConstants.ASGREM | 60 | right |
TagConstants.ASGADD | 60 | right |
TagConstants.ASGSUB | 60 | right |
TagConstants.ASGLSHIFT | 60 | right |
TagConstants.ASGRSHIFT | 60 | right |
TagConstants.ASGURSHIFT | 60 | right |
TagConstants.ASGBITAND | 60 | right |
TagConstants.ASGBITOR | 60 | right |
TagConstants.ASGBITXOR | 60 | right |
(The operators ?
and instanceof
are
treated specially by the parser, but this special treatment
respects the precedence levels indicated above.)
public Expr parseExpression(Lex l)
Does operator-precedence parsing of a large amount of the Expression hierarchy, all the way down to UnaryExpression.
Expression: UnaryExpression Expression BinaryOp Expression Expression instanceof Type Expression ? Expression : Expression BinaryOp: one of STAR / % PLUS - << >> >>> > >= < <= == != & BITOR ^ && || = *= /= %= += -= <<= >>= >>>= &= |= ^=
This grammar is ambiguous; the precedence parsing machinery resolves the ambiguity appropriately, according to the grammar in chapter 19 of "The Java Language Specification".
public Expr parseUnaryExpression(Lex l)
UnaryExpression: PLUS UnaryExpression - UnaryExpression ++ UnaryExpression -- UnaryExpression ~ UnaryExpression ! UnaryExpression PrimaryExpression CastExpressionA CastExpression (as opposed to a PrimaryExpression) is recognised by the lookahead sequences:
LPAREN PrimitiveType LPAREN Name (LSQBRACKET RSQBRACKET)* RPAREN Xwhere X is the first token of a UnaryExpressionNotPlusMinus, cf. isStartOfUnaryExpressionNotPlusMinus(-).
public boolean isStartOfUnaryExpressionNotPlusMinus(int tag)
public Expr parseCastExpression(Lex l)
CastExpression: ( PrimitiveType Dimsopt ) UnaryExpression ( Name Dimsopt ) UnaryExpressionNotPlusMinusThe non-terminal UnaryExpressionNotPlusMinus describes a subset of UnaryExpression as described in chapter 19 of "The Java Language Specification"
protected Expr parsePrimaryExpression(Lex l)
PrimaryExpression: PrimaryCore PrimarySuffix* PrimaryCore: Literal Name Name ArgumentList this super . Identifier super . Identifier ArgumentList NewExpression LPAREN Expression RPAREN TypeName . this [1.1] Type . class [1.1] (This allows void . class because we treat void as a primitive type) PrimarySuffix: ++ -- LSQBRACKET Expression RSQBRACKET . Identifier . Identifier ArgumentList
protected Expr parseClassLiteralSuffix(Lex l, Type t)
protected Expr parsePrimarySuffix(Lex l, Expr primary)
public Expr parseNewExpression(Lex l)
NewExpression: new TypeName ArgumentList [ TypeDeclBody ] new PrimitiveTypeOrTypeName DimExpr+ BracketPairs* DimExpr: LSQBRACKET Expression RSQBRACKET
public Expr parseNewExpressionTail(Lex l, Type type, int locNew)
public ExprVec parseArgumentList(Lex l)
ArgumentList: LPAREN [ Expression (, Expression)* ] RPAREN
public ExprVec parseExpressionList(Lex l, int terminator)
ExpressionList: [ Expression (, Expression)* ]
public Name parseSuper(Lex l)
public VarInit parseVariableInitializer(Lex l, boolean specOnly)
VariableInitializer: Expression ArrayInitializer ArrayInitializer: { [ VariableInitializer ( , VariableInitializer )*] ,opt }
public ArrayInit parseArrayInitializer(Lex l)
|
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 |