org.apache.myfaces.trinidadbuild.plugin.javascript.javascript20parser.js2.0.jjt Maven / Gradle / Ivy
The newest version!
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
options {
STATIC=false;
MULTI=true;
VISITOR=true;
NODE_USES_PARSER=true;
DEBUG_TOKEN_MANAGER=false;
DEBUG_PARSER=false;
}
PARSER_BEGIN(JSParser20)
package org.apache.myfaces.trinidadbuild.plugin.javascript.javascript20parser;
import java.io.IOException;
public class JSParser20
{
//
// This is the root node for the parse tree (root DOM node, tree of SimpleNode(s))
//
protected ASTProgram _jjtRoot;
public ASTProgram getRootNode()
{
return _jjtRoot;
}
}
PARSER_END(JSParser20)
/////////////////////////////////////////////////////
// LEXICAL RULES Section
/////////////////////////////////////////////////////
TOKEN_MGR_DECLS :
{
private boolean isRegValid = true;
public void setRegInvalid()
{
isRegValid = false;
}
public void setRegValid()
{
isRegValid = true;
}
}
/////////////////////////////////////////////////////
// WHITE SPACE
/////////////////////////////////////////////////////
SPECIAL_TOKEN :
{
|
}
/////////////////////////////////////////////////////
// COMMENTS
/////////////////////////////////////////////////////
MORE :
{
"//" : IN_SINGLE_LINE_COMMENT
| "/*" : IN_MULTI_LINE_COMMENT
}
SPECIAL_TOKEN :
{
< SINGLE_LINE_COMMENT: (~["\n","\r"])* ("\n"|"\r"|"\r\n")? > : DEFAULT
}
SPECIAL_TOKEN :
{
: DEFAULT
}
MORE :
{
< ~[] >
}
/////////////////////////////////////////////////////
// RESERVED WORDS AND LITERALS
/////////////////////////////////////////////////////
TOKEN :
{
< AS: "as" >
| < BREAK: "break" >
| < CASE: "case" >
| < CATCH: "catch" >
| < CLASS: "class" >
| < CONST: "const" >
| < CONTINUE: "continue" >
| < _DEFAULT: "default" >
| < DELETE: "delete" >
| < DO: "do" >
| < ELSE: "else" >
| < EXTENDS: "extends" >
| < FALSE: "false" >
| < FINALLY: "finally" >
| < FOR: "for" >
| < FUNCTION: "function" >
| < FUNCTION_: "Function" >
| < GET: "get" >
| < IF: "if" >
| < IN: "in" >
| < INCLUDE: "include" >
| < INSTANCEOF: "instanceof" >
| < IS: "is" >
| < NAMESPACE: "namespace" >
| < NEW: "new" >
| < NULL: "null" >
| < PACKAGE: "package" >
| < PRIVATE: "private" >
| < PUBLIC: "public" >
| < RETURN: "return" >
| < SET: "set" >
| < SUPER: "super" >
| < SWITCH: "switch" >
| < THIS: "this" >
| < THROW: "throw" >
| < TRUE: "true" >
| < TRY: "try" >
| < TYPEOF: "typeof" >
| < USE: "use" >
| < VAR: "var" >
| < VOID: "void" >
| < WHILE: "while" >
| < WITH: "with" >
}
/////////////////////////////////////////////////////
// FUTURE RESERVED WORDS
/////////////////////////////////////////////////////
TOKEN :
{
< ABSTRACT: "abstract" >
| < DEBUGGER: "debugger" >
| < ENUM: "enum" >
| < EXPORT: "export" >
| < GOTO: "goto" >
| < IMPLEMENTS: "implements" >
| < INTERFACE: "interface" >
| < NATIVE: "native" >
| < PROTECTED: "protected" >
| < SYNCHRONIZED: "synchronized" >
| < THROWS: "throws" >
| < TRANSIENT: "transient" >
| < VOLATILE: "volatile" >
| < IMPORT: "import" >
}
/////////////////////////////////////////////////////
// LITERALS
/////////////////////////////////////////////////////
TOKEN :
{
< 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"])* ()?
| "." (["0"-"9"])+ ()?
| (["0"-"9"])+ ()?
>
| < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
| < STRING_LITERAL: "\""
( (~["\"","\\","\n","\r"]) | )*
"\""
| "\""
( (~["\"","\\"]) | "\\" ("\n" | "\r" | "\r\n") | )*
"\""
| "'"
( (~["'","\\","\n","\r"]) | )*
"'"
>
| < #ESCAPE_SEQUENCE:
"\\"
( ["n","t","b","r","f","\\","'","\"","[","]"]
| ["0"-"7"] ( ["0"-"7"] )?
| ["0"-"3"] ["0"-"7"] ["0"-"7"]
| ["x"] ["0"-"9","a"-"f","A"-"F"] ["0"-"9","a"-"f","A"-"F"]
| ["u"] ["0"-"9","a"-"f","A"-"F"] ["0"-"9","a"-"f","A"-"F"]
["0"-"9","a"-"f","A"-"F"] ["0"-"9","a"-"f","A"-"F"]
)
>
| < UNTERMINATED_STRING_LITERAL:
"\"" ( (~["\"","\\","\n","\r"]) | )* ( ["\n","\r"] )?
| "'" ( (~["'","\\","\n","\r"]) | )* ( ["\n","\r"] )?
>
}
/////////////////////////////////////////////////////
// REGULAR EXPRESSIONS
/////////////////////////////////////////////////////
TOKEN :
{
< #REGX_START_CHAR : ~["\r","\n","/","=","*"] | "\\/">
| < #REGX_BODY_CHAR_EXCLUSION : ~["\r","\n","/"] >
| < #REGX_BODY_CHAR : ( | "\\/" ) >
| < #REGEX_END_CHAR : "i"
| "g"
| "m"
| "ig"
| "im"
| "gi"
| "gm"
| "mi"
| "mg"
| "igm"
| "img"
| "gmi"
| "gim"
| "mig"
| "mgi"
>
}
TOKEN :
{
()* "/" ()? >
{
try {
// Peek at the next character.
char nextCh = input_stream.readChar();
input_stream.backup(1);
if (isRegValid == false || nextCh == '/' || nextCh == '*') {
//
// Lexecal analyser thinks it is a RE
// operator such as /...../
// Put the everything to the first "/" back on the input stream
//
input_stream.backup(lengthOfMatch-1);
//
// And remove it from the token
//
matchedToken.image = matchedToken.image.substring(0, 1);
image.delete(0, image.length() - 1);
image.append('/');
matchedToken.kind=SLASH;
}
} catch (IOException e) {
throw new Error(e.toString());
}
}
}
/////////////////////////////////////////////////////
// IDENTIFIERS
/////////////////////////////////////////////////////
TOKEN :
{
< IDENTIFIER: (|)* >
| < #LETTER: ["a"-"z","A"-"Z","$","_"] >
| < #DIGIT: ["0"-"9"]>
}
/////////////////////////////////////////////////////
// SEPARATORS
/////////////////////////////////////////////////////
TOKEN :
{
< LPAREN: "(" >
| < RPAREN: ")" >
| < LBRACE: "{" >
| < RBRACE: "}" >
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < SEMICOLON: ";" >
| < COMMA: "," >
| < DOT: "." >
| < QUALIFIER: "::" >
| < ELIPSE: "..." >
}
/////////////////////////////////////////////////////
// OPERATORS
/////////////////////////////////////////////////////
TOKEN :
{
< ASSIGN: "=" >
| < GT: ">" >
| < LT: "<" >
| < BANG: "!" >
| < TILDE: "~" >
| < HOOK: "?" >
| < COLON: ":" >
| < EQ: "==" >
| < LE: "<=" >
| < GE: ">=" >
| < NE: "!=" >
| < SC_OR: "||" >
| < SC_AND: "&&" >
| < SC_XOR: "^^" >
| < 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: ">>>=" >
| < SC_ORASSIGN: "||=" >
| < SC_ANDASSIGN: "&&=" >
| < SC_XORASSIGN: "^^=" >
| < IDENTITYOPER: "===" >
| < NOTIDENTITYOPER: "!==" >
}
///////////////////////////////////////////////////////////////////
// GRAMMAR Section
///////////////////////////////////////////////////////////////////
Token Program():
{
Token retval = getToken(1);
}
{
(PackageDefinition())* [Directives()]
{
_jjtRoot = jjtThis;
return retval;
}
}
/////////////////////////////////////////////////////
// Expressions
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
// Identifier
/////////////////////////////////////////////////////
void Identifier():
{}
{
|
|
|
// |
}
/////////////////////////////////////////////////////
// Qualified Identifier
/////////////////////////////////////////////////////
void SimpleQualifiedIdentifier():
{}
{
Identifier() [ Identifier()]
| ReservedNamespace() [ Identifier()]
}
void ExpressionQualifiedIdentifier():
{}
{
AssignmentExpression() Identifier()
}
void QualifiedIdentifier():
{}
{
SimpleQualifiedIdentifier()
| ExpressionQualifiedIdentifier()
}
/////////////////////////////////////////////////////
// Primary Expressions
/////////////////////////////////////////////////////
void PrimaryExpression ():
{}
{
(
|
|
|
|
|
|
|
|
|
| ListExpression()
| ArrayLiteral()
| ObjectLiteral()
| FunctionExpression()
)
{
token_source.setRegValid();
}
}
void ReservedNamespace ():
{}
{
|
|
}
/////////////////////////////////////////////////////
// Function Expression
/////////////////////////////////////////////////////
void FunctionExpression ():
{}
{
LOOKAHEAD(2) FunctionCommon()
| Identifier() FunctionCommon()
}
/////////////////////////////////////////////////////
// Object Literals
/////////////////////////////////////////////////////
void ObjectLiteral ():
{}
{
[FieldList()]
}
void FieldList():
{}
{
LiteralField() ( LiteralField())*
}
void LiteralField ():
{}
{
FieldName() AssignmentExpression()
}
void FieldName ():
{}
{
|
| SimpleQualifiedIdentifier()
| AssignmentExpression() [ Identifier()]
}
/////////////////////////////////////////////////////
// Array Literal
/////////////////////////////////////////////////////
void ArrayLiteral():
{}
{
[ElementList()]
}
void ElementList():
{}
{
LiteralElement() ( LiteralElement())*
}
void LiteralElement():
{}
{
AssignmentExpression()
}
/////////////////////////////////////////////////////
// Super Expression
/////////////////////////////////////////////////////
void SuperExpression ():
{}
{
[LOOKAHEAD(2) AssignmentExpression() ]
}
/////////////////////////////////////////////////////
// Postfix Expression
/////////////////////////////////////////////////////
void PostfixExpression ():
{}
{
AttributeExpression () [PostfixOp()]
| {token_source.setRegInvalid();}
FullPostfixExpression () (PropertyOrArguments())* [PostfixOp()]
| SuperExpression() PropertyOperator()
}
void AttributeExpression ():
{}
{
SimpleQualifiedIdentifier() (PropertyOrArguments())*
}
void FullPostfixExpression ():
{}
{
LOOKAHEAD( AssignmentExpression() )
ExpressionQualifiedIdentifier()
| PrimaryExpression()
| FullNewExpression()
}
void FullNewExpression ():
{}
{
FullNewSubexpression() (LOOKAHEAD(2) PropertyOperator())* [LOOKAHEAD(2) Arguments()]
}
void FunctionConstructor():
{}
{
Arguments()
}
void FullNewSubexpression ():
{}
{
LOOKAHEAD( AssignmentExpression() )
ExpressionQualifiedIdentifier()
| PrimaryExpression()
| SimpleQualifiedIdentifier()
| SuperExpression()
| FullNewExpression()
| FunctionConstructor()
}
void PostfixOp():
{}
{
|
}
void PropertyOrArguments ():
{}
{
Arguments()
| PropertyOperator()
}
/////////////////////////////////////////////////////
// Property Operators
/////////////////////////////////////////////////////
void PropertyOperator ():
{}
{
QualifiedIdentifier()
| LOOKAHEAD(2)
| LOOKAHEAD(2) AssignmentExpression()
| ListExpression() [ AssignmentExpression()]
}
void Arguments ():
{{token_source.setRegValid();}}
{
LOOKAHEAD(2)
| LOOKAHEAD(2) AssignmentExpression()
| ListExpression() [ AssignmentExpression()]
}
/////////////////////////////////////////////////////
// Unary Operators
/////////////////////////////////////////////////////
void UnaryExpression ():
{}
{
PostfixExpression()
| PostfixExpression()
| UnaryExpression()
| UnaryExpression()
| PostfixExpression()
| PostfixExpression()
| UnaryExpression()
| UnaryExpression()
| UnaryExpression()
| UnaryExpression()
}
/////////////////////////////////////////////////////
// Multiplicative Operators
/////////////////////////////////////////////////////
void MulOp():
{}
{
|
|
}
void MultiplicativeExpression():
{}
{
UnaryExpression() (MulOp() UnaryExpression())*
}
/////////////////////////////////////////////////////
// Additive Operators
/////////////////////////////////////////////////////
void AddOp():
{}
{
|
}
void AdditiveExpression():
{}
{
MultiplicativeExpression() (AddOp() MultiplicativeExpression())*
}
/////////////////////////////////////////////////////
// Bitwise Shift Operators
/////////////////////////////////////////////////////
void ShiftOp():
{}
{
|
|
}
void ShiftExpression():
{}
{
AdditiveExpression() (ShiftOp() AdditiveExpression())*
}
/////////////////////////////////////////////////////
// Relational Operators
/////////////////////////////////////////////////////
void RelOp():
{}
{
|
|
|
|
|
}
void RelationalExpression():
{}
{
ShiftExpression()
(LOOKAHEAD(3)(RelOp() | | ) ShiftExpression())*
}
void RelationalExpressionNoIN():
{}
{
ShiftExpression()
((RelOp() | ) ShiftExpression())*
}
/////////////////////////////////////////////////////
// Equality Operators
/////////////////////////////////////////////////////
void EqualOp():
{}
{
|
|
|
}
void EqualityExpression():
{}
{
RelationalExpression() (EqualOp() RelationalExpression())*
}
void EqualityExpressionNoIN():
{}
{
RelationalExpressionNoIN() (EqualOp() RelationalExpressionNoIN())*
}
/////////////////////////////////////////////////////
// Binary Bitwise Operators
/////////////////////////////////////////////////////
void BitwiseANDOp():
{}
{
}
void BitwiseANDExpression():
{}
{
EqualityExpression() (BitwiseANDOp() EqualityExpression())*
}
void BitwiseANDExpressionNoIN():
{}
{
EqualityExpressionNoIN() (BitwiseANDOp() EqualityExpressionNoIN())*
}
void BitwiseXOROp():
{}
{
}
void BitwiseXORExpression():
{}
{
BitwiseANDExpression() (BitwiseXOROp() BitwiseANDExpression())*
}
void BitwiseXORExpressionNoIN():
{}
{
BitwiseANDExpressionNoIN() (BitwiseXOROp() BitwiseANDExpressionNoIN())*
}
void BitwiseOROp():
{}
{
}
void BitwiseORExpression():
{}
{
BitwiseXORExpression() (BitwiseOROp() BitwiseXORExpression())*
}
void BitwiseORExpressionNoIN():
{}
{
BitwiseXORExpressionNoIN() (BitwiseOROp() BitwiseXORExpressionNoIN())*
}
/////////////////////////////////////////////////////
// Binary Logical Operators
/////////////////////////////////////////////////////
void LogicalANDExpression():
{}
{
BitwiseORExpression() ( BitwiseORExpression())*
}
void LogicalANDExpressionNoIN():
{}
{
BitwiseORExpressionNoIN() ( BitwiseORExpressionNoIN())*
}
void LogicalORExpression():
{}
{
LogicalANDExpression() ( LogicalANDExpression())*
}
void LogicalORExpressionNoIN():
{}
{
LogicalANDExpressionNoIN() ( LogicalANDExpressionNoIN())*
}
/////////////////////////////////////////////////////
// Conditional Operators
/////////////////////////////////////////////////////
void ConditionalExpression():
{}
{
LogicalORExpression() [ AssignmentExpression()
AssignmentExpression()]
}
void ConditionalExpressionNoIN():
{}
{
LogicalORExpressionNoIN() [ AssignmentExpressionNoIN()
AssignmentExpressionNoIN()]
}
void NonAssignmentExpression():
{}
{
LogicalORExpression() [ NonAssignmentExpression()
NonAssignmentExpression()]
}
void NonAssignmentExpressionNoIN():
{}
{
LogicalORExpressionNoIN() [ NonAssignmentExpressionNoIN()
NonAssignmentExpressionNoIN()]
}
/////////////////////////////////////////////////////
// Assignment Operators
/////////////////////////////////////////////////////
void AssignementOperator():
{}
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
void AssignmentExpression():
{}
{
ConditionalExpression() [LOOKAHEAD(2) AssignementOperator() AssignmentExpression()]
}
void AssignmentExpressionNoIN():
{}
{
ConditionalExpressionNoIN() [LOOKAHEAD(2) AssignementOperator() AssignmentExpressionNoIN()]
}
/////////////////////////////////////////////////////
// Comma Expressions
/////////////////////////////////////////////////////
void ListExpression ():
{}
{
AssignmentExpression() ( AssignmentExpression())*
}
void ListExpressionNoIN ():
{}
{
AssignmentExpressionNoIN() ( AssignmentExpressionNoIN())*
}
/////////////////////////////////////////////////////
// Type Expressions
/////////////////////////////////////////////////////
void TypeExpression ():
{}
{
NonAssignmentExpression()
}
void TypeExpressionNoIN ():
{}
{
NonAssignmentExpressionNoIN()
}
void TypeExpressionList ():
{}
{
NonAssignmentExpression() ( NonAssignmentExpression())*
}
/////////////////////////////////////////////////////
// Staements (abbrev, noShortIf, full)
/////////////////////////////////////////////////////
void Statement ():
{}
{
LOOKAHEAD(3) ExpressionStatement() Sc()
| SuperStatement() Sc()
| Block()
| LabeledStatement()
| IfStatement()
| SwitchStatement()
| DoStatement() Sc()
| WhileStatement()
| ForStatement()
| WithStatement()
| ContinueStatement() Sc()
| BreakStatement() Sc()
| ReturnStatement() Sc()
| ThrowStatement() Sc()
| TryStatement()
}
void Substatement ():
{}
{
EmptyStatement()
| LOOKAHEAD(2) Statement()
| SimpleVariableDefinition() Sc()
| Attributes() Substatements()
}
void Substatements ():
{}
{
(Substatement())+
}
JAVACODE
void Sc() {
Token tok = getToken(1);
if (tok.kind == SEMICOLON) {
tok = getNextToken();
} else if (tok.specialToken != null) {
if (!EolCommentSkipWs(tok.specialToken) && (tok.kind != EOF)) {
throw generateParseException();
}
} else if ((tok.kind != EOF) && (tok.kind!=RBRACE)) {
throw generateParseException();
}
}
JAVACODE
boolean EolCommentSkipWs(Token t) {
boolean retVal = false;
Token specialToken = t;
while(specialToken != null) {
if(specialToken.kind == WS) {
specialToken = specialToken.specialToken;
continue;
}
else if(specialToken.kind == EOL ||
specialToken.kind == SINGLE_LINE_COMMENT) {
retVal = true;
break;
}
else {
break;
}
}
return retVal;
}
/////////////////////////////////////////////////////
// Empty Statement
/////////////////////////////////////////////////////
void EmptyStatement():
{}
{
}
/////////////////////////////////////////////////////
// Expresion Statement
/////////////////////////////////////////////////////
void ExpressionStatement():
{}
{
ListExpression()
}
/////////////////////////////////////////////////////
// Super Statement
/////////////////////////////////////////////////////
void SuperStatement ():
{}
{
Arguments()
}
/////////////////////////////////////////////////////
// Block Statement
/////////////////////////////////////////////////////
void Block ():
{}
{
[Directives()]
}
/////////////////////////////////////////////////////
// Labeled Statement (maps to literal field)
/////////////////////////////////////////////////////
void LabeledStatement ():
{}
{
Identifier() Substatement()
}
/////////////////////////////////////////////////////
// If Statement
/////////////////////////////////////////////////////
void IfStatement():
{}
{
ListExpression()
Substatement()
[LOOKAHEAD(1) Substatement()]
}
/////////////////////////////////////////////////////
// Switch Statement
/////////////////////////////////////////////////////
void SwitchStatement ():
{}
{
ListExpression()
[CaseElements()]
}
void CaseElements ():
{}
{
CaseLabel() (CaseElement())*
}
void CaseElement ():
{}
{
Directive()
| CaseLabel()
}
void CaseLabel ():
{}
{
ListExpression()
| <_DEFAULT>
}
/////////////////////////////////////////////////////
// Do-While Statement
/////////////////////////////////////////////////////
void DoStatement():
{}
{
Substatement() ListExpression()
}
/////////////////////////////////////////////////////
// While Statement
/////////////////////////////////////////////////////
void WhileStatement ():
{}
{
ListExpression()
Substatement()
}
/////////////////////////////////////////////////////
// For Statements
/////////////////////////////////////////////////////
void ForStatement ():
{}
{
LOOKAHEAD( ForInBinding() )
ForInBinding() ListExpression()
Substatement()
| [ForInitializer()]
[ListExpression()]
[ListExpression()]
Substatement()
}
void ForInitializer ():
{}
{
LOOKAHEAD(3) ListExpressionNoIN()
| VariableDefinitionNoIN()
| Attributes() VariableDefinitionNoIN()
}
void ForInBinding ():
{}
{
LOOKAHEAD(3) PostfixExpression()
| VariableDefinitionKind() VariableBindingNoIN()
| Attributes() VariableDefinitionKind() VariableBindingNoIN()
}
/////////////////////////////////////////////////////
// With Statement
/////////////////////////////////////////////////////
void WithStatement():
{}
{
ExpressionStatement()
Substatement()
}
/////////////////////////////////////////////////////
// Continue and Break Statement
/////////////////////////////////////////////////////
void ContinueStatement():
{}
{
[Identifier()]
}
void BreakStatement():
{}
{
[Identifier()]
}
/////////////////////////////////////////////////////
// Return Statement
/////////////////////////////////////////////////////
void ReturnStatement():
{}
{
[ListExpression()]
}
/////////////////////////////////////////////////////
// Throw Statement
/////////////////////////////////////////////////////
void ThrowStatement():
{}
{
ListExpression()
}
/////////////////////////////////////////////////////
// Try Statement
/////////////////////////////////////////////////////
void TryStatement():
{}
{
Block()
( Identifier() Block())*
[ Block()]
}
/////////////////////////////////////////////////////
// Directives
/////////////////////////////////////////////////////
void Directives ():
{}
{
(Directive())+
}
void Directive ():
{}
{
EmptyStatement()
| LOOKAHEAD(3) Statement()
| LOOKAHEAD(2) AnnotatableDirective()
| LOOKAHEAD(2) Attributes() Directives()
| LOOKAHEAD(2) Attributes() AnnotatableDirective()
| IncludeDirective() Sc()
| Pragma() Sc()
}
void AnnotatableDirective ():
{}
{
VariableDefinition() Sc()
| FunctionDefinition()
| ClassDefinition()
| InterfaceDefinition()
| NamespaceDefinition() Sc()
| ImportDirective() Sc()
| ExportDefinition() Sc()
| UseDirective() Sc()
}
/////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////
void Attributes ():
{}
{
(Attribute ())+
}
void Attribute ():
{}
{
AttributeExpression()
|
|
}
/////////////////////////////////////////////////////
// Use Directive
/////////////////////////////////////////////////////
void UseDirective ():
{}
{