/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
options {
JAVA_UNICODE_ESCAPE = true;
STATIC = false;
}
public class ExpressionParser {
private static GetFrame lastFrameGetter;
private static LValue lastLValue;
}
}
}
}
public interface GetFrame {
}
// TODO StringBufferInputStream is deprecated.
parser.Expression();
return lastLValue.getValue();
}
try {
return;
}
} else {
return;
}
try {
parser.Expression();
} catch (ParseException e) {
}
}
}
SKIP : /* WHITE SPACE */
{
" "
| "\t"
| "\n"
| "\r"
| "\f"
}
SPECIAL_TOKEN : /* COMMENTS */
{
}
TOKEN : /* RESERVED WORDS AND LITERALS */
{
< ABSTRACT: "abstract" >
| < BOOLEAN: "boolean" >
| < BREAK: "break" >
| < BYTE: "byte" >
| < CASE: "case" >
| < CATCH: "catch" >
| < CHAR: "char" >
| < CLASS: "class" >
| < CONST: "const" >
| < CONTINUE: "continue" >
| < _DEFAULT: "default" >
| < DO: "do" >
| < DOUBLE: "double" >
| < ELSE: "else" >
| < EXTENDS: "extends" >
| < FALSE: "false" >
| < FINAL: "final" >
| < FINALLY: "finally" >
| < FLOAT: "float" >
| < FOR: "for" >
| < GOTO: "goto" >
| < IF: "if" >
| < IMPLEMENTS: "implements" >
| < IMPORT: "import" >
| < INSTANCEOF: "instanceof" >
| < INT: "int" >
| < INTERFACE: "interface" >
| < LONG: "long" >
| < NATIVE: "native" >
| < NEW: "new" >
| < NULL: "null" >
| < PACKAGE: "package">
| < PRIVATE: "private" >
| < PROTECTED: "protected" >
| < PUBLIC: "public" >
| < RETURN: "return" >
| < SHORT: "short" >
| < STATIC: "static" >
| < SUPER: "super" >
| < SWITCH: "switch" >
| < SYNCHRONIZED: "synchronized" >
| < THIS: "this" >
| < THROW: "throw" >
| < THROWS: "throws" >
| < TRANSIENT: "transient" >
| < TRUE: "true" >
| < TRY: "try" >
| < VOID: "void" >
| < VOLATILE: "volatile" >
| < WHILE: "while" >
}
TOKEN : /* LITERALS */
{
<
>
|
|
|
|
>
|
|
"'"
( (~["'","\\","\n","\r"])
| ("\\"
( ["n","t","b","r","f","\\","'","\""]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)
"'"
>
|
"\""
( (~["\"","\\","\n","\r"])
| ("\\"
( ["n","t","b","r","f","\\","'","\""]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)*
"\""
>
}
TOKEN : /* IDENTIFIERS */
{
|
< #LETTER:
[
"\u0024",
"\u0041"-"\u005a",
"\u005f",
"\u0061"-"\u007a",
"\u00c0"-"\u00d6",
"\u00d8"-"\u00f6",
"\u00f8"-"\u00ff",
"\u0100"-"\u1fff",
"\u3040"-"\u318f",
"\u3300"-"\u337f",
"\u3400"-"\u3d2d",
"\u4e00"-"\u9fff",
"\uf900"-"\ufaff"
]
>
|
< #DIGIT:
[
"\u0030"-"\u0039",
"\u0660"-"\u0669",
"\u06f0"-"\u06f9",
"\u0966"-"\u096f",
"\u09e6"-"\u09ef",
"\u0a66"-"\u0a6f",
"\u0ae6"-"\u0aef",
"\u0b66"-"\u0b6f",
"\u0be7"-"\u0bef",
"\u0c66"-"\u0c6f",
"\u0ce6"-"\u0cef",
"\u0d66"-"\u0d6f",
"\u0e50"-"\u0e59",
"\u0ed0"-"\u0ed9",
"\u1040"-"\u1049"
]
>
}
TOKEN : /* SEPARATORS */
{
< LPAREN: "(" >
| < RPAREN: ")" >
| < LBRACE: "{" >
| < RBRACE: "}" >
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < SEMICOLON: ";" >
| < COMMA: "," >
| < DOT: "." >
}
TOKEN : /* OPERATORS */
{
< ASSIGN: "=" >
| < GT: ">" >
| < LT: "<" >
| < BANG: "!" >
| < TILDE: "~" >
| < HOOK: "?" >
| < COLON: ":" >
| < EQ: "==" >
| < LE: "<=" >
| < GE: ">=" >
| < NE: "!=" >
| < SC_OR: "||" >
| < SC_AND: "&&" >
| < INCR: "++" >
| < DECR: "--" >
| < PLUS: "+" >
| < MINUS: "-" >
| < STAR: "*" >
| < SLASH: "/" >
| < BIT_AND: "&" >
| < BIT_OR: "|" >
| < XOR: "^" >
| < REM: "%" >
| < LSHIFT: "<<" >
| < RSIGNEDSHIFT: ">>" >
| < RUNSIGNEDSHIFT: ">>>" >
| < PLUSASSIGN: "+=" >
| < MINUSASSIGN: "-=" >
| < STARASSIGN: "*=" >
| < SLASHASSIGN: "/=" >
| < ANDASSIGN: "&=" >
| < ORASSIGN: "|=" >
| < XORASSIGN: "^=" >
| < REMASSIGN: "%=" >
| < LSHIFTASSIGN: "<<=" >
| < RSIGNEDSHIFTASSIGN: ">>=" >
| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
}
/*****************************************
* THE JAVA LANGUAGE GRAMMAR STARTS HERE *
*****************************************/
/*
* Type, name and expression syntax follows.
*/
void Type() :
{}
{
}
void PrimitiveType() :
{}
{
"boolean"
|
"char"
|
"byte"
|
"short"
|
"int"
|
"long"
|
"float"
|
"double"
}
{
)*
}
void NameList() :
{}
{
Name()
( "," Name()
)*
}
/*
* Expression syntax follows.
*/
void Expression() :
{}
{
|
}
void Assignment() :
{}
{
}
void AssignmentOperator() :
{}
{
"=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
}
void ConditionalExpression() :
{}
{
if (cond instanceof BooleanValue) {
} else {
throw new ParseException("Condition must be boolean");
}
}
]
}
void ConditionalOrExpression() :
{}
{
( "||" ConditionalAndExpression()
{ throw new ParseException("operation not yet supported"); }
)*
}
void ConditionalAndExpression() :
{}
{
( "&&" InclusiveOrExpression()
{ throw new ParseException("operation not yet supported"); }
)*
}
void InclusiveOrExpression() :
{}
{
( "|" ExclusiveOrExpression()
{ throw new ParseException("operation not yet supported"); }
)*
}
void ExclusiveOrExpression() :
{}
{
( "^" AndExpression()
{ throw new ParseException("operation not yet supported"); }
)*
}
void AndExpression() :
{}
{
( "&" EqualityExpression()
{ throw new ParseException("operation not yet supported"); }
)*
}
void EqualityExpression() :
{
)*
}
void InstanceOfExpression() :
{}
{
[ "instanceof" Type()
{ throw new ParseException("operation not yet supported"); }
]
}
void RelationalExpression() :
{
)*
}
void ShiftExpression() :
{}
{
{ throw new ParseException("operation not yet supported"); }
)*
}
void AdditiveExpression() :
{
)*
}
void MultiplicativeExpression() :
{
)*
}
void UnaryExpression() :
{}
{
{ throw new ParseException("operation not yet supported"); }
|
|
|
}
void PreIncrementExpression() :
{}
{
"++" PrimaryExpression()
{ throw new ParseException("operation not yet supported"); }
}
void PreDecrementExpression() :
{}
{
"--" PrimaryExpression()
{ throw new ParseException("operation not yet supported"); }
}
void UnaryExpressionNotPlusMinus() :
{}
{
{ throw new ParseException("operation not yet supported"); }
|
LOOKAHEAD( CastLookahead() )
|
}
// This production is to determine lookahead only. The LOOKAHEAD specifications
// below are not used, but they are there just to indicate that we know about
// this.
void CastLookahead() :
{}
{
LOOKAHEAD(2)
"(" PrimitiveType()
|
|
}
void PostfixExpression() :
{}
{
[ "++" | "--"
{ throw new ParseException("operation not yet supported"); }
]
}
void CastExpression() :
{}
{
LOOKAHEAD(2)
|
}
void PrimaryExpression() :
{}
{
PrimaryPrefix() ( PrimarySuffix() )*
}
void PrimaryPrefix() :
{
Literal()
|
|
"this"
|
"super" "." <IDENTIFIER>
{ throw new ParseException("operation not yet supported"); }
|
|
}
void PrimarySuffix() :
{
|
"." <IDENTIFIER>
|
}
void Literal() :
{}
{
|
|
|
|
|
}
void BooleanLiteral() :
{}
{
"true"
|
"false"
}
void NullLiteral() :
{}
{
"null"
}
{
{ return argList; }
}
{}
{
}
void AllocationExpression() :
{
LOOKAHEAD(2)
|
| ArrayDimensions()
{ throw new ParseException("operation not yet supported"); }
)
}
/*
* The second LOOKAHEAD specification below is to parse to PrimarySuffix
* if there is an expression between the "[...]".
*/
void ArrayDimensions() :
{}
{
}