Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
.openl.grammars.5.10.3.source-code.jgrammar.jj Maven / Gradle / Ivy
options {
// see CharStream.html in doc for JavaCC
// input streams were edited manually!
UNICODE_INPUT = true;
// TODO: JAVA_UNICODE_ESCAPE = true;
COMMON_TOKEN_ACTION = true;
LOOKAHEAD=1;
STATIC=false;
}
PARSER_BEGIN(JGrammar)
package org.openl.grammar.jgrammar;
public class JGrammar extends org.openl.grammar.JavaCC30Grammar
{
public JGrammar()
{
this(new java.io.StringReader(""));
}
protected org.openl.util.text.IPosition begin(Token t)
{
return pos(t.beginLine, t.beginColumn);
}
protected org.openl.util.text.IPosition end(Token t)
{
return pos(t.endLine, t.endColumn);
}
protected org.openl.util.text.TextInterval pos(Token t)
{
return t == null ? null : new org.openl.util.text.TextInterval(begin(t), end(t));
}
protected org.openl.util.text.TextInterval pos(Token t1, Token t2)
{
return new org.openl.util.text.TextInterval(begin(t1), end(t2));
}
protected org.openl.util.text.TextInterval pos(
String lexError,
Token t,
StringBuffer resMessage)
{
String prefix = "Lexical error at line ";
if (!lexError.startsWith(prefix))
{
resMessage.append(lexError);
return pos(t);
}
lexError = lexError.substring(prefix.length());
int i = 0;
int line = 0;
int col = 0;
while (Character.isDigit(lexError.charAt(i)))
{
line = line * 10 + lexError.charAt(i) - '0';
++i;
}
String prefix2 = ", column ";
i += prefix2.length();
while (Character.isDigit(lexError.charAt(i)))
{
col = col * 10 + lexError.charAt(i) - '0';
++i;
}
resMessage.append(lexError.substring(i + 2));
return new org.openl.util.text.TextInterval(
pos(line, col),
pos(line, col));
}
public void parseTopNode(String type)
{
try
{
if (type.equals("method.body"))
parseTopNodeInternal();
else if (type.equals("method.header"))
MethodHeader();
else if (type.equals("module"))
parseModuleInternal();
else if (type.equals("type"))
Type();
}
catch (ParseException pe)
{
//pe.printStackTrace();
//throw pe;
syntaxBuilder.addError(
new org.openl.syntax.exception.SyntaxNodeException(
pe.getMessage(),
null,
pos(pe.currentToken),
syntaxBuilder.getModule()));
}
catch (TokenMgrError err)
{
StringBuffer buf = new StringBuffer();
org.openl.util.text.TextInterval loc =
pos(err.getMessage(), token, buf);
syntaxBuilder.addError(
new org.openl.syntax.exception.SyntaxNodeException(buf.toString(), null, loc, syntaxBuilder.getModule()));
}
catch (Exception e)
{
syntaxBuilder.addError(new org.openl.syntax.exception.SyntaxNodeException("", e, pos(token), syntaxBuilder.getModule()));
}
catch (Throwable t)
{
syntaxBuilder.addError(new org.openl.syntax.exception.SyntaxNodeException("", t, pos(token), syntaxBuilder.getModule()));
}
}
} //EOF JGrammar
PARSER_END(JGrammar)
TOKEN_MGR_DECLS:
{
// CommonTokenAction: use the begins/ends fields added to the Jack
// CharStream class to set corresponding fields in each Token (which was
// also extended with new fields). By default Jack doesn't supply absolute
// offsets, just line/column offsets
void CommonTokenAction(Token t)
{
// t.beginsAt = input_stream.beginOffset;
// t.endsAt = input_stream.endOffset;
// throw new RuntimeException("Define CommonTokenAction");
/*
org.openl.util.Log.debug(
"Token = <"
+ t.image
+ "> "
+ "("
+ t.beginLine
+ ","
+ t.beginColumn
+ ")-("
+ t.endLine
+ ","
+ t.endColumn
+ ")"
+ " "
+ t.kind
+ " = "
+ JGrammarConstants.tokenImage[t.kind]);
*/
} // CommonTokenAction
} // TOKEN_MGR_DECLS
SKIP :
{
" "
| "\r"
| "\t"
| "\n"
| "\f"
}
/*
TOKEN :
{
< EOL: "\n" >
}
*/
/* JAVA RESERVED WORDS AND LITERALS */
TOKEN :
{
< 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" >
}
/* SEPARATORS */
TOKEN :
{
< LPAREN: "(" >
| < RPAREN: ")" >
| < LBRACE: "{" >
| < RBRACE: "}" >
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < SEMICOLON: ";" >
| < COMMA: "," >
| < DOT: "." >
}
/* OPERATORS */
TOKEN :
{
< 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: ">>>=" >
| < EXP: "**" >
| < IMPL: "->" >
}
/* JAVA LITERALS */
TOKEN :
{
< INTEGER_LITERAL:
// (["+","-"])? (["l","L"])?
(["l","L"])?
| (["l","L"])?
| (["l","L"])?
>
|
< #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
|
< #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
|
< #OCTAL_LITERAL: "0" (["0"-"7"])* >
|
< FLOATING_POINT_LITERAL:
(["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F","d","D"])?
| "." (["0"-"9"])+ ()? (["f","F","d","D"])?
| (["0"-"9"])+ (["f","F","d","D"])?
| (["0"-"9"])+ ()? ["f","F","d","D"]
>
|
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
|
< CHARACTER_LITERAL:
"'"
( (~["'","\\","\n","\r"])
| ("\\"
( ["n","t","b","r","f","\\","'","\""]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
)
)
)
"'"
>
|
< STRING_LITERAL:
"\""
( (~["\"","\\","\n","\r"])
| ("\\"
( ["n","t","b","r","f","\\","'","\""]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
| "u" (["0"-"9"]|["a"-"f"]) (["0"-"9"]|["a"-"f"])(["0"-"9"]|["a"-"f"])(["0"-"9"]|["a"-"f"])
)
)
)*
"\""
>
}
/* IDENTIFIERS */
TOKEN :
{
< IDENTIFIER: (|)* >
|
< #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"
]
>
}
/* COMMENTS */
MORE :
{
// "//" : IN_SINGLE_LINE_COMMENT
//|
<"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
|
"/*" : IN_MULTI_LINE_COMMENT
}
//
//SPECIAL_TOKEN :
//{
// : DEFAULT
//}
SPECIAL_TOKEN:
{
< SINGLE_LINE_COMMENT : "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")? >
}
SPECIAL_TOKEN :
{
: DEFAULT
}
SPECIAL_TOKEN :
{
: DEFAULT
}
//
MORE :
{
< ~[] >
}
/*
* Expression syntax follows.
*/
void Expression() :
{
Token x;
String func = null;
}
{
ConditionalExpression()
[
( x = "=" {func="op.assign";}
| x = "+=" {func="op.assign.add";}
| x = "-=" {func="op.assign.subtract";}
| x = "*=" {func="op.assign.multiply";}
| x = "/=" {func="op.assign.divide";}
| x = "&=" {func="op.assign.bitand";}
| x = "|=" {func="op.assign.bitor";}
| x = "^=" {func="op.assign.bitnot";}
| x = "%=" {func="op.assign.rem";}
)
Expression()
{
syntaxBuilder.bop(func, pos(x));
}
]
}
void ConditionalExpression() :
{Token x;}
{
ConditionalImplExpression()
[ x="?" ConditionalExpression() ":" ConditionalExpression()
{ syntaxBuilder.nop("op.conditional.qmark", pos(x), 3); }
]
}
void ConditionalImplExpression() :
{Token x;}
{
ConditionalOrExpression()
(
LOOKAHEAD( )
(x = ) ConditionalOrExpression()
{ syntaxBuilder.bop("op.binary.impl", pos(x)); }
)*
}
void ConditionalOrExpression() :
{Token x;}
{
ConditionalXorExpression() ( x= ConditionalXorExpression()
{ syntaxBuilder.bop("op.binary.or", pos(x)); } )*
}
void ConditionalXorExpression() :
{Token x;}
{
ConditionalAndExpression() (
x= ConditionalAndExpression()
{ syntaxBuilder.bop("op.binary.xor", pos(x)); } )*
}
void ConditionalAndExpression() :
{Token x;}
{
EqualityExpression()
( x= EqualityExpression()
{ syntaxBuilder.bop("op.binary.and", pos(x)); } )*
}
void EqualityExpression() :
{
Token x;
String func = null;
}
{
RelationalExpression()
(
( x = {func="eq";}
| x = {func="ne";}
)
RelationalExpression()
{syntaxBuilder.bop("op.binary." + func, pos(x));}
)*
}
void RelationalExpression() :
{
Token x;
String func = null;
}
{
AdditiveExpression()
(
( x = {func="lt";}
| x = {func="gt";}
| x = {func="le";}
| x = {func="ge";}
)
AdditiveExpression()
{
{syntaxBuilder.bop("op.binary." + func, pos(x));}
}
)*
}
void AdditiveExpression() :
{
Token x;
String func = null;
}
{
MultiplicativeExpression()
(
(x= {func="add";}| x= {func="subtract";})
MultiplicativeExpression()
{syntaxBuilder.bop("op.binary." + func, pos(x));}
)*
}
void MultiplicativeExpression() :
{
Token x;
String func = null;
}
{
PowerExpression()
(
( x = {func="multiply";} | x = {func="divide";}| x = {func="rem";})
PowerExpression()
{syntaxBuilder.bop("op.binary." + func, pos(x));}
)*
}
void PowerExpression() :
{Token x;}
{
UnaryExpression()
(
LOOKAHEAD( )
x= UnaryExpression()
{syntaxBuilder.bop("op.binary.pow", pos(x));}
)*
}
void UnaryExpression() :
{Token x;}
{
x= UnaryExpression()
{syntaxBuilder.uop("op.unary.positive", pos(x));}
|
x= UnaryExpression()
{syntaxBuilder.uop("op.unary.negative", pos(x));}
|
x= UnaryExpression()
{syntaxBuilder.uop("op.unary.not", pos(x));}
|
PreIncrementExpression()
|
PreDecrementExpression()
|
LOOKAHEAD( CastLookahead() )
CastExpression()
|
PostfixExpression()
}
void PreIncrementExpression() :
{Token x;}
{
x="++" PrimaryExpression()
{ syntaxBuilder.uop("op.prefix.inc", pos(x)); }
}
void PreDecrementExpression() :
{Token x;}
{
x="--" PrimaryExpression() { syntaxBuilder.uop("op.prefix.dec", pos(x)); }
}
void PostfixExpression() :
{Token x;}
{
PrimaryExpression()
[ x="++"
{ syntaxBuilder.uop("op.suffix.inc", pos(x)); }
| x="--"
{ syntaxBuilder.uop("op.suffix.dec", pos(x)); }
]
}
void PrimaryExpression() :
{
int args = 1;
}
{
PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() {++args;} )*
{
if (args > 1)
syntaxBuilder.nop("chain", null, args);
}
}
void PrimaryPrefix() :
{}
{
Literal()
|
AbsExpression()
|
"(" Expression() ")"
|
AllocationExpression()
//|
// LOOKAHEAD( ResultType() "." "class" )
// ResultType() "." "class"
// { syntaxBuilder.identifier("ident", token.image); syntaxBuilder.nop(".chain",2); }
|
LOOKAHEAD( function() ) function()
|
identifier()
//| BlockClosure()
}
void PrimarySuffix() :
{}
{
index()
| LOOKAHEAD( "." function() ) "." function()
| "." identifier()
}
void CastExpression() :
{Token x1, x2;}
{
x1="(" Type() x2=")" UnaryExpression()
{ syntaxBuilder.bop("type.cast", pos(x1,x2)); }
}
void CastLookahead() :
{}
{
"(" Type() ")" ( "~" | "!" | "(" | "[" | | "new" | Literal() )
}
void identifier() :
{}
{
{
syntaxBuilder.identifier("identifier", pos(token),token.image);
}
}
void TypeDimension() :
{Token x1, x2;}
{
x1="[" x2="]"
{
syntaxBuilder.uop("type.index", pos(x1, x2));
}
}
void Type() :
{
}
{
// ( PrimitiveType() | ClassName() ) ( TypeDimension() )*
ClassName() ( TypeDimension() )*
{syntaxBuilder.uop("type.declaration", null);}
}
void ResultType() :
{}
{
"void"
{
syntaxBuilder.identifier("type.name",pos(token),token.image);
syntaxBuilder.uop("type.declaration", null);
}
|
Type()
}
void ClassName() :
{
String name;
Token x1, x2;
}
{
x1= {name = token.image; x2=x1;}
( LOOKAHEAD(2) "." x2= {name = name + "." + token.image;}
)*
{ syntaxBuilder.identifier("type.name",pos(x1, x2),name); }
}
void function() :
{
String funcname;
int args = 0;
Token x1, x2;
}
{
x1= {funcname = token.image;}
"("
[ Expression() {args++;} ( "," Expression() {args++;})* ]
x2=")"
{
syntaxBuilder.identifier("funcname", pos(x1), funcname);
syntaxBuilder.nop("function", pos(x1,x2), args + 1);
}
}
void AllocationExpression() :
{
int args = 0;
Token x1, x2;
}
{
x1="new" ClassName()
(
"("
[ Expression() {args++;} ( "," Expression() {args++;})* ]
x2=")"
{
syntaxBuilder.nop("op.new.object",pos(x1, x2), args + 1);
}
|
ArrayDimsAndInits()
{
syntaxBuilder.uop("op.new.array",pos(x1));
}
)
}
/*
* The second LOOKAHEAD specification below is to parse to PrimarySuffix
* if there is an expression between the "[...]".
*/
void ArrayDimsAndInits() :
{
Token x1, x2;
int cnt = 0;
}
{
LOOKAHEAD(2)
( LOOKAHEAD(2) x1="[" Expression() x2="]" {syntaxBuilder.bop("array.index.expression", pos(x1, x2)); cnt++;} )+
( LOOKAHEAD(2) x1="[" x2="]" {syntaxBuilder.uop("array.index.empty", pos(x1, x2));} )*
|
( TypeDimension() )+ ArrayInitializer()
}
void index() :
{Token x1,x2;}
{
x1="["
Expression()
x2="]"
{
syntaxBuilder.uop("op.index", pos(x1, x2));
}
}
void AbsExpression() :
{Token x1, x2;}
{
x1="|" Expression() x2="|"
{
syntaxBuilder.uop("|.|", pos(x1,x2));
}
}
void Literal() :
{}
{
{ syntaxBuilder.literal("literal.integer", pos(token), token.image); }
|
{ syntaxBuilder.literal("literal.real", pos(token), token.image); }
|
{ syntaxBuilder.literal("literal.string", pos(token), token.image); }
|
{ syntaxBuilder.literal("literal.char", pos(token), token.image); }
|
BooleanLiteral()
|
NullLiteral()
}
void BooleanLiteral() :
{}
{
{syntaxBuilder.literal("literal.bool", pos(token), token.image);}
|
{syntaxBuilder.literal("literal.bool", pos(token), token.image);}
}
void NullLiteral() :
{}
{
{syntaxBuilder.literal("literal.null", pos(token), token.image);}
}
void Block() :
{Token x1, x2;}
{
x1="{"
BlockStatementList()
x2="}"
{
//syntaxBuilder.uop("{}", pos(x1, x2));
}
}
void BlockStatementList() :
{
int args = 0;
}
{
( BlockStatement() {args++;} )*
{
syntaxBuilder.nop("block.statement", null, args);
}
}
void OptionalSemiColon() :
{}
{
( | )
}
void Statement() :
{}
{
LOOKAHEAD(2)
LabeledStatement()
|
Block()
|
EmptyStatement()
|
StatementExpression() OptionalSemiColon()
|
IfStatement()
|
WhileStatement()
|
DoStatement()
|
ForStatement()
|
BreakStatement()
|
ContinueStatement()
|
ReturnStatement()
|
ThrowStatement()
}
void LabeledStatement() :
{
String label;
}
{
{label = token.image; } ":"
{ syntaxBuilder.notImplemented("startLabel(label)"); }
Statement()
{ syntaxBuilder.notImplemented("endLabel()"); }
}
void BlockStatement() :
{}
{
LOOKAHEAD(Type() )
LocalVariableDeclaration() OptionalSemiColon()
|
Statement()
}
void StatementExpression() :
{}
{
Expression()
}
void EmptyStatement() :
{}
{
{ syntaxBuilder.emptyStatement(token.image, pos(token)); }
}
void IfStatement() :
{
Token x1;
int nodes = 2;
}
{
x1= "(" Expression() ")" Statement()
[ LOOKAHEAD(1) Statement() { ++nodes; }]
{ syntaxBuilder.nop("control.if", pos(x1), nodes ); }
}
void WhileStatement() :
{
Token x;
}
{
// { syntaxBuilder.notImplemented("startLabel(null)"); } // anonymous label for cycles
x="while" "(" Expression() ")" Statement() { syntaxBuilder.bop("control.while", pos(x)); }
// { syntaxBuilder.notImplemented("endLabel()"); }
}
void ReturnStatement() :
{
int args = 0;
Token x;
}
{
x = "return" [ Expression() {++args;} ] ";"
{syntaxBuilder.nop("control.return", pos(x), args);}
}
void ThrowStatement() :
{}
{
"throw" Expression() ";"
}
void DoStatement() :
{}
{
{ syntaxBuilder.notImplemented("startLabel(null)"); } // anonymous label for cycles
"do" Statement() "while" "(" Expression() ")" OptionalSemiColon() { syntaxBuilder.notImplemented("doStatement()"); }
{ syntaxBuilder.notImplemented("endLabel()"); }
}
void LocalVariableDeclaration() :
{
int args = 0;
}
{
Type() VariableDeclarator() {args++;} ( "," VariableDeclarator() {args++;})*
{
syntaxBuilder.nop("local.var.declaration", null, args + 1);
}
}
void VariableDeclarator() :
{
boolean withInitializer = false;
}
{
VariableDeclaratorId() [ "=" VariableInitializer() {withInitializer=true;} ]
{
if (withInitializer)
{
syntaxBuilder.bop("local.var.name.init", null);
}
else
{
// syntaxBuilder.uop("local.name.noinit", pos(x));
}
// syntaxBuilder.notImplemented("varDeclarator(withInitializer)");
}
}
void VariableDeclaratorId() :
{}
{
identifier() ( TypeDimension() )*
}
void VariableInitializer() :
{}
{
ArrayInitializer()
|
Expression()
}
void ArrayInitializer() :
{
int args = 0;
Token x1, x2;
}
{
x1 ="{"
[ VariableInitializer() {args++;}
( LOOKAHEAD(2) "," VariableInitializer() {args++;} )*
]
[ "," ]
x2 ="}"
{ syntaxBuilder.nop("array.init", pos(x1, x2),args); }
}
void ForStatement() :
{
boolean[] bParts = new boolean[4];
Token x;
}
{
{
//!!!syntaxBuilder.notImplemented("startLabel(null)");
} // anonymous label for cycles
x = "for" "("
[ ForInit() {bParts[0] = true;} ]
[ Expression() {bParts[1] = true;} ]
[ ForUpdate() {bParts[2] = true;} ]
")" Statement() {bParts[3] = true;}
{
syntaxBuilder.nop("control.for", pos(x) ,bParts);
}
{
//!!!syntaxBuilder.notImplemented("endLabel()");
}
}
void ForInit() :
{}
{
LOOKAHEAD( Type() )
LocalVariableDeclaration()
|
StatementExpressionList()
}
void StatementExpressionList() :
{
int args = 0;
}
{
StatementExpression() {args++;} ( "," StatementExpression() {args++;} )*
{
if (args > 1)
syntaxBuilder.nop("statement_list",null, args);
}
}
void ForUpdate() :
{}
{
StatementExpressionList()
}
void BreakStatement() :
{
String label=null;
}
{
"break" [ {label = token.image; } ] OptionalSemiColon()
{syntaxBuilder.notImplemented("doBreak(label)");}
}
void ContinueStatement() :
{
String label = null;
}
{
"continue" [ {label = token.image; } ] OptionalSemiColon()
{syntaxBuilder.notImplemented("doContinue(label)");}
}
void MethodHeader():
{}
{
( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
ResultType() MethodDeclarator()
{syntaxBuilder.nop("method.header", null, 3);}
}
void MethodDeclaration() :
{}
{
// ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" | "strictfp")*
( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*
ResultType() MethodDeclarator()
//[ "throws" NameList() ]
( Block() {syntaxBuilder.nop("method.declaration", null, 4);} | ";" )
}
void MethodDeclarator() :
{}
{
MethodName() FormalParameters() //( "[" "]" )*
}
void MethodName() :
{}
{
identifier()
}
void FormalParameters() :
{
int args = 0;
Token x1, x2;
}
{
x1 = "(" [ FormalParameter() {++args;} ( "," FormalParameter() {++args;} )* ] x2=")"
{syntaxBuilder.nop("method.parameters", pos(x1,x2), args);}
}
void FormalParameter() :
{
// java.util.Map map = new java.util.HashMap();
}
{
// [ "final" {map.put("final", "final");} ]
Type() VariableDeclaratorId()
// [
// "in" {map.put("in", "in");}
// |
// "out" {map.put("out", "out");}
// |
// "inout" {map.put("inout", "inout");}
// ]
{
syntaxBuilder.nop("parameter.declaration", null, 2);
}
}
void VarDeclaration() :
{
}
{
LocalVariableDeclaration() ";"
{syntaxBuilder.uop("var.declaration", null);}
}
void MethodOrVarDeclaration() :
{
}
{
LOOKAHEAD(ResultType() MethodDeclarator())
MethodDeclaration()
|
VarDeclaration()
}
void parseModuleInternal() :
{
int nMethods = 1;
}
{
// MethodDeclaration() (MethodDeclaration() {++nMethods;})*
MethodOrVarDeclaration() (MethodOrVarDeclaration() {++nMethods;})*
{ if (nMethods > 0) syntaxBuilder.nop("module.top", null, nMethods); }
}
/*
*/
void parseTopNodeInternal() :
{}
{
BlockStatementList()
{ syntaxBuilder.uop("block.top", null); }
// parseMethodsInternal()
}
//void ParameterDeclaration() :
//{
// int args = 0;
//}
//{
// [ Type() {args++;} ] ":" identifier()
// {
// _ipr.parameterDeclaration(args);
// }
//}
//
//void ParameterDeclarations() :
//{
// int args = 0;
//}
//{
// ParameterDeclaration() {args++;} ( "," ParameterDeclaration() {args++;} )*
// { _ipr.parameterDeclarations(args); }
//}
//
//
//void BlockClosure() :
//{
// int args = 0;
//}
//{
// "["
// [ LOOKAHEAD(ParameterDeclaration()) ParameterDeclarations() "|" { args++; } ]
// BlockStatementList()
// "]"
// { _ipr.blockClosure(args); }
//
//}
//