MiraplacidTextDataDefinitionFileInfo { version 2; credits "Miraplacid Software"; license "CC BY-SA 3.0"; comments "Java format"; extensions "java"; mime_types "application/java-source"; include "clang.tdd"; IgnoreWhiteSpace; greedy; CommentTokens "/*" "*/"; CommentTokens "//" "\n"; start Java; } IdLetter = [a-zA-Z_$]; IdAlphaNumeric = [a-zA-Z_0-9$]; Identifier = {IdLetter}{IdAlphaNumeric}*; StringLiteral = {STRING}; FloatingPointLiteral = {FLOATING}; BooleanLiteral = 'true' | 'false'; NullLiteral = 'null'; CharacterLiteral = {CHARACTER}; IntegerLiteral = {INTEGER_DEC} | {INTEGER_OCT} | {INTEGER_HEX}; Literal = IntegerLiteral | FloatingPointLiteral | BooleanLiteral | CharacterLiteral | StringLiteral | NullLiteral; Type = PrimitiveType | ReferenceType; PrimitiveType = NumericType | 'boolean'; NumericType = IntegralType | FloatingPointType; IntegralType = 'byte' | 'short' | 'int' | 'long' | 'char'; FloatingPointType = 'float' | 'double'; ReferenceType = ArrayType | ClassOrInterfaceType; ClassOrInterfaceType = Name; ClassType = ClassOrInterfaceType; InterfaceType = ClassOrInterfaceType; ArrayType = PrimitiveType '[' ']' | Name '[' ']' | ArrayType '[' ']'; Name = SimpleName ('.' SimpleName)*; SimpleName = Identifier; QualifiedName = SimpleName ('.' SimpleName)+; Java = (PackageDeclaration ImportDeclarations TypeDeclarations | PackageDeclaration ImportDeclarations | PackageDeclaration TypeDeclarations | PackageDeclaration | ImportDeclarations TypeDeclarations | ImportDeclarations | TypeDeclarations)?; ImportDeclarations = ImportDeclaration+; TypeDeclarations = TypeDeclaration+; PackageDeclaration = 'package' Name ';'; ImportDeclaration = SingleTypeImportDeclaration | TypeImportOnDemandDeclaration; SingleTypeImportDeclaration = 'import' Name ';'; TypeImportOnDemandDeclaration = 'import' Name '.' '*' ';'; TypeDeclaration = ClassDeclaration | InterfaceDeclaration | ';'; Modifiers = Modifier+; Modifier = 'public' | 'protected' | 'private' | 'static' | 'abstract' | 'final' | 'native' | 'synchronized' | 'transient' | 'volatile'; ClassDeclaration = Modifiers 'class' Identifier Super Interfaces ClassBody | Modifiers 'class' Identifier Super ClassBody | Modifiers 'class' Identifier Interfaces ClassBody | Modifiers 'class' Identifier ClassBody | 'class' Identifier Super Interfaces ClassBody | 'class' Identifier Super ClassBody | 'class' Identifier Interfaces ClassBody | 'class' Identifier ClassBody; Super = 'extends' ClassType; Interfaces = 'implements' InterfaceTypeList; InterfaceTypeList = InterfaceType (',' InterfaceType)*; ClassBody = '{' ClassBodyDeclarations? '}'; ClassBodyDeclarations = ClassBodyDeclaration+; ClassBodyDeclaration = ClassMemberDeclaration | StaticInitializer | ConstructorDeclaration; ClassMemberDeclaration = FieldDeclaration | MethodDeclaration; FieldDeclaration = Modifiers Type VariableDeclarators ';' | Type VariableDeclarators ';'; VariableDeclarators = VariableDeclarator (',' VariableDeclarator)*; VariableDeclarator = VariableDeclaratorId | VariableDeclaratorId '=' VariableInitializer; VariableDeclaratorId = Identifier | VariableDeclaratorId '[' ']'; VariableInitializer = Expression | ArrayInitializer; MethodDeclaration = MethodHeader MethodBody; MethodHeader = Modifiers Type MethodDeclarator Throws | Modifiers Type MethodDeclarator | Type MethodDeclarator Throws | Type MethodDeclarator | Modifiers 'void' MethodDeclarator Throws | Modifiers 'void' MethodDeclarator | 'void' MethodDeclarator Throws | 'void' MethodDeclarator; MethodDeclarator = Identifier '(' FormalParameterList ')' | Identifier '(' ')' | MethodDeclarator '[' ']'; FormalParameterList = FormalParameter (',' FormalParameter)*; FormalParameter = Type VariableDeclaratorId; Throws = 'throws' ClassTypeList; ClassTypeList = ClassType (',' ClassType)*; MethodBody = Block | ';'; StaticInitializer = 'static' Block; ConstructorDeclaration = Modifiers ConstructorDeclarator Throws ConstructorBody | Modifiers ConstructorDeclarator ConstructorBody | ConstructorDeclarator Throws ConstructorBody | ConstructorDeclarator ConstructorBody; ConstructorDeclarator = SimpleName '(' FormalParameterList ')' | SimpleName '(' ')'; ConstructorBody = '{' ExplicitConstructorInvocation BlockStatements '}' | '{' ExplicitConstructorInvocation '}' | '{' BlockStatements '}' | '{' '}'; ExplicitConstructorInvocation = 'this' '(' ArgumentList ')' ';' | 'this' '(' ')' ';' | 'super' '(' ArgumentList ')' ';' | 'super' '(' ')' ';'; InterfaceDeclaration = Modifiers 'interface' Identifier ExtendsInterfaces InterfaceBody | Modifiers 'interface' Identifier InterfaceBody | 'interface' Identifier ExtendsInterfaces InterfaceBody | 'interface' Identifier InterfaceBody; ExtendsInterfaces = 'extends' InterfaceType (',' InterfaceType)*; InterfaceBody = '{' InterfaceMemberDeclarations? '}'; InterfaceMemberDeclarations = InterfaceMemberDeclaration+; InterfaceMemberDeclaration = ConstantDeclaration | AbstractMethodDeclaration; ConstantDeclaration = FieldDeclaration; AbstractMethodDeclaration = MethodHeader ';'; ArrayInitializer = '{' VariableInitializers ',' '}' | '{' VariableInitializers '}' | '{' ',' '}' | '{' '}'; VariableInitializers = VariableInitializer (',' VariableInitializer)*; Block = '{' BlockStatements? '}'; BlockStatements = BlockStatement+; BlockStatement = LocalVariableDeclarationStatement | Statement; LocalVariableDeclarationStatement = LocalVariableDeclaration ';'; LocalVariableDeclaration = Type VariableDeclarators; Statement = StatementWithoutTrailingSubstatement | LabeledStatement | IfThenStatement | IfThenElseStatement | WhileStatement | ForStatement; StatementNoShortIf = StatementWithoutTrailingSubstatement | LabeledStatementNoShortIf | IfThenElseStatementNoShortIf | WhileStatementNoShortIf | ForStatementNoShortIf; StatementWithoutTrailingSubstatement = Block | EmptyStatement | ExpressionStatement | SwitchStatement | DoStatement | BreakStatement | ContinueStatement | ReturnStatement | SynchronizedStatement | ThrowStatement | TryStatement; EmptyStatement = ';'; LabeledStatement = Identifier ':' Statement; LabeledStatementNoShortIf = Identifier ':' StatementNoShortIf; ExpressionStatement = StatementExpression ';'; StatementExpression = Assignment | PreIncrementExpression | PreDecrementExpression | PostIncrementExpression | PostDecrementExpression | MethodInvocation | ClassInstanceCreationExpression; IfThenStatement = 'if' '(' Expression ')' Statement; IfThenElseStatement = 'if' '(' Expression ')' StatementNoShortIf 'else' Statement; IfThenElseStatementNoShortIf = 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf; SwitchStatement = 'switch' '(' Expression ')' SwitchBlock; SwitchBlock = '{' SwitchBlockStatementGroups SwitchLabels '}' | '{' SwitchBlockStatementGroups '}' | '{' SwitchLabels '}' | '{' '}'; SwitchBlockStatementGroups = SwitchBlockStatementGroup+; SwitchBlockStatementGroup = SwitchLabels BlockStatements; SwitchLabels = SwitchLabel+; SwitchLabel = 'case' ConstantExpression ':' | 'default' ':'; WhileStatement = 'while' '(' Expression ')' Statement; WhileStatementNoShortIf = 'while' '(' Expression ')' StatementNoShortIf; DoStatement = 'do' Statement 'while' '(' Expression ')' ';'; ForStatement = 'for' '(' ForInit ';' Expression ';' ForUpdate ')' Statement | 'for' '(' ForInit ';' Expression ';' ')' Statement | 'for' '(' ForInit ';' ';' ForUpdate ')' Statement | 'for' '(' ForInit ';' ';' ')' Statement | 'for' '(' ';' Expression ';' ForUpdate ')' Statement | 'for' '(' ';' Expression ';' ')' Statement | 'for' '(' ';' ';' ForUpdate ')' Statement | 'for' '(' ';' ';' ')' Statement; ForStatementNoShortIf = 'for' '(' ForInit ';' Expression ';' ForUpdate ')' StatementNoShortIf | 'for' '(' ForInit ';' Expression ';' ')' StatementNoShortIf | 'for' '(' ForInit ';' ';' ForUpdate ')' StatementNoShortIf | 'for' '(' ForInit ';' ';' ')' StatementNoShortIf | 'for' '(' ';' Expression ';' ForUpdate ')' StatementNoShortIf | 'for' '(' ';' Expression ';' ')' StatementNoShortIf | 'for' '(' ';' ';' ForUpdate ')' StatementNoShortIf | 'for' '(' ';' ';' ')' StatementNoShortIf; ForInit = StatementExpressionList | LocalVariableDeclaration; ForUpdate = StatementExpressionList; StatementExpressionList = StatementExpression (',' StatementExpression)*; BreakStatement = 'break' Identifier ';' | 'break' ';'; ContinueStatement = 'continue' Identifier ';' | 'continue' ';'; ReturnStatement = 'return' Expression ';' | 'return' ';'; ThrowStatement = 'throw' Expression ';'; SynchronizedStatement = 'synchronized' '(' Expression ')' Block; TryStatement = 'try' Block Catches | 'try' Block Catches Finally | 'try' Block Finally; Catches = CatchClause+; CatchClause = 'catch' '(' FormalParameter ')' Block; Finally = 'finally' Block; Primary = PrimaryNoNewArray | ArrayCreationExpression; PrimaryNoNewArray = 'this' | '(' Expression ')' | Literal | ClassInstanceCreationExpression | MethodInvocation | ArrayAccess | FieldAccess; ClassInstanceCreationExpression = 'new' ClassType '(' ArgumentList ')' | 'new' ClassType '(' ')'; ArgumentList = Expression (',' Expression)*; ArrayCreationExpression = 'new' PrimitiveType DimExprs Dims | 'new' PrimitiveType DimExprs | 'new' ClassOrInterfaceType DimExprs Dims | 'new' ClassOrInterfaceType DimExprs; DimExprs = DimExpr+; DimExpr = '[' Expression ']'; Dims = '[' ']' ('[' ']')*; FieldAccess = Primary '.' Identifier | 'super' '.' Identifier; MethodInvocation = 'super' '.' Identifier '(' ArgumentList ')' | 'super' '.' Identifier '(' ')' | Primary '.' Identifier '(' ArgumentList ')' | Primary '.' Identifier '(' ')' | Name '(' ArgumentList ')' | Name '(' ')'; ArrayAccess = Name '[' Expression ']' | PrimaryNoNewArray '[' Expression ']'; PostfixExpression = Primary | Name | PostIncrementExpression | PostDecrementExpression; PostIncrementExpression = PostfixExpression '++'; PostDecrementExpression = PostfixExpression '--'; UnaryExpression = PreIncrementExpression | PreDecrementExpression | '+' UnaryExpression | '-' UnaryExpression | UnaryExpressionNotPlusMinus; PreIncrementExpression = '++' UnaryExpression; PreDecrementExpression = '--' UnaryExpression; UnaryExpressionNotPlusMinus = PostfixExpression | '~' UnaryExpression | '!' UnaryExpression | CastExpression; CastExpression = '(' PrimitiveType Dims ')' UnaryExpression | '(' PrimitiveType ')' UnaryExpression | '(' Expression ')' UnaryExpressionNotPlusMinus | '(' Name Dims ')' UnaryExpressionNotPlusMinus; MultiplicativeExpression = UnaryExpression | MultiplicativeExpression '*' UnaryExpression | MultiplicativeExpression '/' UnaryExpression | MultiplicativeExpression '%' UnaryExpression; AdditiveExpression = MultiplicativeExpression | AdditiveExpression '+' MultiplicativeExpression | AdditiveExpression '-' MultiplicativeExpression; ShiftExpression = AdditiveExpression | ShiftExpression '<<' AdditiveExpression | ShiftExpression '>>' AdditiveExpression | ShiftExpression '>>>' AdditiveExpression; RelationalExpression = ShiftExpression | RelationalExpression '<' ShiftExpression | RelationalExpression '>' ShiftExpression | RelationalExpression '<=' ShiftExpression | RelationalExpression '>=' ShiftExpression | RelationalExpression 'instanceof' ReferenceType; EqualityExpression = RelationalExpression | EqualityExpression '==' RelationalExpression | EqualityExpression '!=' RelationalExpression; AndExpression = EqualityExpression | AndExpression '&' EqualityExpression; ExclusiveOrExpression = AndExpression | ExclusiveOrExpression '^' AndExpression; InclusiveOrExpression = ExclusiveOrExpression | InclusiveOrExpression '|' ExclusiveOrExpression; ConditionalAndExpression = InclusiveOrExpression | ConditionalAndExpression '&&' InclusiveOrExpression; ConditionalOrExpression = ConditionalAndExpression | ConditionalOrExpression '||' ConditionalAndExpression; ConditionalExpression = ConditionalOrExpression | ConditionalOrExpression '?' Expression ':' ConditionalExpression; AssignmentExpression = ConditionalExpression | Assignment; Assignment = LeftHandSide AssignmentOperator AssignmentExpression; LeftHandSide = Name | FieldAccess | ArrayAccess; AssignmentOperator = '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='; Expression = AssignmentExpression; ConstantExpression = Expression;