Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@967 ab42f6e0-554d-0410-b580-99e487e6eeb2
- Loading branch information
1 parent
482e839
commit 1abcefd
Showing
3 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
all: | ||
cd ../../../extraction/antlr && make build | ||
make build | ||
|
||
build: | ||
java -cp ${CLASSPATH}:../../../../download/antlrworks-1.1.7.jar:../../../extraction/antlr slps.antlr2bgf.Tool parr/Java.stripped.g parr.bgf | ||
|
||
clean: | ||
rm *.bgf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
grammar Java; | ||
compilationUnit: annotations ( packageDeclaration importDeclaration* typeDeclaration*| classOrInterfaceDeclaration typeDeclaration*)| packageDeclaration? importDeclaration* typeDeclaration*; | ||
packageDeclaration: 'package' qualifiedName ';'; | ||
importDeclaration: 'import' 'static'? qualifiedName ('.' '*')? ';'; | ||
typeDeclaration: classOrInterfaceDeclaration | ';'; | ||
classOrInterfaceDeclaration: classOrInterfaceModifiers (classDeclaration | interfaceDeclaration); | ||
classOrInterfaceModifiers: classOrInterfaceModifier*; | ||
classOrInterfaceModifier: annotation | 'public'| 'protected'| 'private'| 'abstract'| 'static'| 'final'| 'strictfp'; | ||
modifiers: modifier*; | ||
classDeclaration: normalClassDeclaration | enumDeclaration ; | ||
normalClassDeclaration: 'class' Identifier typeParameters? ('extends' type)? ('implements' typeList)? classBody ; | ||
typeParameters: '<' typeParameter (',' typeParameter)* '>'; | ||
typeParameter: Identifier ('extends' typeBound)?; | ||
typeBound: type ('&' type)*; | ||
enumDeclaration: ENUM Identifier ('implements' typeList)? enumBody ; | ||
enumBody: '{' enumConstants? ','? enumBodyDeclarations? '}'; | ||
enumConstants: enumConstant (',' enumConstant)*; | ||
enumConstant: annotations? Identifier arguments? classBody?; | ||
enumBodyDeclarations: ';' (classBodyDeclaration)*; | ||
interfaceDeclaration: normalInterfaceDeclaration | annotationTypeDeclaration ; | ||
normalInterfaceDeclaration: 'interface' Identifier typeParameters? ('extends' typeList)? interfaceBody ; | ||
typeList: type (',' type)*; | ||
classBody: '{' classBodyDeclaration* '}'; | ||
interfaceBody: '{' interfaceBodyDeclaration* '}'; | ||
classBodyDeclaration: ';'| 'static'? block | modifiers memberDecl ; | ||
memberDecl: genericMethodOrConstructorDecl | memberDeclaration | 'void' Identifier voidMethodDeclaratorRest | Identifier constructorDeclaratorRest | interfaceDeclaration | classDeclaration ; | ||
memberDeclaration: type (methodDeclaration | fieldDeclaration); | ||
genericMethodOrConstructorDecl: typeParameters genericMethodOrConstructorRest ; | ||
genericMethodOrConstructorRest: (type | 'void') Identifier methodDeclaratorRest | Identifier constructorDeclaratorRest ; | ||
methodDeclaration: Identifier methodDeclaratorRest ; | ||
fieldDeclaration: variableDeclarators ';'; | ||
interfaceBodyDeclaration: modifiers interfaceMemberDecl | ';'; | ||
interfaceMemberDecl: interfaceMethodOrFieldDecl | interfaceGenericMethodDecl | 'void' Identifier voidInterfaceMethodDeclaratorRest | interfaceDeclaration | classDeclaration ; | ||
interfaceMethodOrFieldDecl: type Identifier interfaceMethodOrFieldRest ; | ||
interfaceMethodOrFieldRest: constantDeclaratorsRest ';'| interfaceMethodDeclaratorRest ; | ||
methodDeclaratorRest: formalParameters ('[' ']')* ('throws' qualifiedNameList)? ( methodBody | ';'); | ||
voidMethodDeclaratorRest: formalParameters ('throws' qualifiedNameList)? ( methodBody | ';'); | ||
interfaceMethodDeclaratorRest: formalParameters ('[' ']')* ('throws' qualifiedNameList)? ';'; | ||
interfaceGenericMethodDecl: typeParameters (type | 'void') Identifier interfaceMethodDeclaratorRest ; | ||
voidInterfaceMethodDeclaratorRest: formalParameters ('throws' qualifiedNameList)? ';'; | ||
constructorDeclaratorRest: formalParameters ('throws' qualifiedNameList)? constructorBody ; | ||
constantDeclarator: Identifier constantDeclaratorRest ; | ||
variableDeclarators: variableDeclarator (',' variableDeclarator)*; | ||
variableDeclarator: variableDeclaratorId ('=' variableInitializer)?; | ||
constantDeclaratorsRest: constantDeclaratorRest (',' constantDeclarator)*; | ||
constantDeclaratorRest: ('[' ']')* '=' variableInitializer ; | ||
variableDeclaratorId: Identifier ('[' ']')*; | ||
variableInitializer: arrayInitializer | expression ; | ||
arrayInitializer: '{' (variableInitializer (',' variableInitializer)* (',')?)? '}'; | ||
modifier: annotation | 'public'| 'protected'| 'private'| 'static'| 'abstract'| 'final'| 'native'| 'synchronized'| 'transient'| 'volatile'| 'strictfp'; | ||
packageOrTypeName: qualifiedName ; | ||
enumConstantName: Identifier ; | ||
typeName: qualifiedName ; | ||
type: classOrInterfaceType ('[' ']')*| primitiveType ('[' ']')*; | ||
classOrInterfaceType: Identifier typeArguments? ('.' Identifier typeArguments?)*; | ||
primitiveType: 'boolean'| 'char'| 'byte'| 'short'| 'int'| 'long'| 'float'| 'double'; | ||
variableModifier: 'final'| annotation ; | ||
typeArguments: '<' typeArgument (',' typeArgument)* '>'; | ||
typeArgument: type | '?' (('extends'| 'super') type)?; | ||
qualifiedNameList: qualifiedName (',' qualifiedName)*; | ||
formalParameters: '(' formalParameterDecls? ')'; | ||
formalParameterDecls: variableModifiers type formalParameterDeclsRest ; | ||
formalParameterDeclsRest: variableDeclaratorId (',' formalParameterDecls)?| '...' variableDeclaratorId ; | ||
methodBody: block ; | ||
constructorBody: '{' explicitConstructorInvocation? blockStatement* '}'; | ||
explicitConstructorInvocation: nonWildcardTypeArguments? ('this'| 'super') arguments ';'| primary '.' nonWildcardTypeArguments? 'super' arguments ';'; | ||
qualifiedName: Identifier ('.' Identifier)*; | ||
literal: integerLiteral | FloatingPointLiteral | CharacterLiteral | StringLiteral | booleanLiteral | 'null'; | ||
integerLiteral: HexLiteral | OctalLiteral | DecimalLiteral ; | ||
booleanLiteral: 'true'| 'false'; | ||
annotations: annotation+; | ||
annotation: '@' annotationName ( '(' ( elementValuePairs | elementValue )? ')')?; | ||
annotationName: Identifier ('.' Identifier)*; | ||
elementValuePairs: elementValuePair (',' elementValuePair)*; | ||
elementValuePair: Identifier '=' elementValue ; | ||
elementValue: conditionalExpression | annotation | elementValueArrayInitializer ; | ||
elementValueArrayInitializer: '{' (elementValue (',' elementValue)*)? (',')? '}'; | ||
annotationTypeDeclaration: '@' 'interface' Identifier annotationTypeBody ; | ||
annotationTypeBody: '{' (annotationTypeElementDeclaration)* '}'; | ||
annotationTypeElementDeclaration: modifiers annotationTypeElementRest ; | ||
annotationTypeElementRest: type annotationMethodOrConstantRest ';'| normalClassDeclaration ';'?| normalInterfaceDeclaration ';'?| enumDeclaration ';'?| annotationTypeDeclaration ';'?; | ||
annotationMethodOrConstantRest: annotationMethodRest | annotationConstantRest ; | ||
annotationMethodRest: Identifier '(' ')' defaultValue?; | ||
annotationConstantRest: variableDeclarators ; | ||
defaultValue: 'default' elementValue ; | ||
block: '{' blockStatement* '}'; | ||
blockStatement: localVariableDeclarationStatement | classOrInterfaceDeclaration | statement ; | ||
localVariableDeclarationStatement: localVariableDeclaration ';'; | ||
localVariableDeclaration: variableModifiers type variableDeclarators ; | ||
variableModifiers: variableModifier*; | ||
statement: block | ASSERT expression (':' expression)? ';'| 'if' parExpression statement ('else' statement)?| 'for' '(' forControl ')' statement | 'while' parExpression statement | 'do' statement 'while' parExpression ';'| 'try' block ( catches 'finally' block | catches | 'finally' block )| 'switch' parExpression '{' switchBlockStatementGroups '}'| 'synchronized' parExpression block | 'return' expression? ';'| 'throw' expression ';'| 'break' Identifier? ';'| 'continue' Identifier? ';'| ';'| statementExpression ';'| Identifier ':' statement ; | ||
catches: catchClause (catchClause)*; | ||
catchClause: 'catch' '(' formalParameter ')' block ; | ||
formalParameter: variableModifiers type variableDeclaratorId ; | ||
switchBlockStatementGroups: (switchBlockStatementGroup)*; | ||
switchBlockStatementGroup: switchLabel+ blockStatement*; | ||
switchLabel: 'case' constantExpression ':'| 'case' enumConstantName ':'| 'default' ':'; | ||
forControl: enhancedForControl | forInit? ';' expression? ';' forUpdate?; | ||
forInit: localVariableDeclaration | expressionList ; | ||
enhancedForControl: variableModifiers type Identifier ':' expression ; | ||
forUpdate: expressionList ; | ||
parExpression: '(' expression ')'; | ||
expressionList: expression (',' expression)*; | ||
statementExpression: expression ; | ||
constantExpression: expression ; | ||
expression: conditionalExpression (assignmentOperator expression)?; | ||
assignmentOperator: '='| '+='| '-='| '*='| '/='| '&='| '|='| '^='| '%='| t1='<' t2='<' t3='=' | t1='>' t2='>' t3='>' t4='=' | t1='>' t2='>' t3='='; | ||
conditionalExpression: conditionalOrExpression ( '?' expression ':' expression )?; | ||
conditionalOrExpression: conditionalAndExpression ( '||' conditionalAndExpression )*; | ||
conditionalAndExpression: inclusiveOrExpression ( '&&' inclusiveOrExpression )*; | ||
inclusiveOrExpression: exclusiveOrExpression ( '|' exclusiveOrExpression )*; | ||
exclusiveOrExpression: andExpression ( '^' andExpression )*; | ||
andExpression: equalityExpression ( '&' equalityExpression )*; | ||
equalityExpression: instanceOfExpression ( ('=='| '!=') instanceOfExpression )*; | ||
instanceOfExpression: relationalExpression ('instanceof' type)?; | ||
relationalExpression: shiftExpression ( relationalOp shiftExpression )*; | ||
relationalOp: t1='<' t2='=' | t1='>' t2='=' | '<'| '>'; | ||
shiftExpression: additiveExpression ( shiftOp additiveExpression )*; | ||
shiftOp: t1='<' t2='<' | t1='>' t2='>' t3='>' | t1='>' t2='>'; | ||
additiveExpression: multiplicativeExpression ( ('+'| '-') multiplicativeExpression )*; | ||
multiplicativeExpression: unaryExpression ( ( '*'| '/'| '%') unaryExpression )*; | ||
unaryExpression: '+' unaryExpression | '-' unaryExpression | '++' unaryExpression | '--' unaryExpression | unaryExpressionNotPlusMinus ; | ||
unaryExpressionNotPlusMinus: '~' unaryExpression | '!' unaryExpression | castExpression | primary selector* ('++'|'--')?; | ||
castExpression: '(' primitiveType ')' unaryExpression | '(' (type | expression) ')' unaryExpressionNotPlusMinus ; | ||
primary: parExpression | 'this' ('.' Identifier)* identifierSuffix?| 'super' superSuffix | literal | 'new' creator | Identifier ('.' Identifier)* identifierSuffix?| primitiveType ('[' ']')* '.' 'class'| 'void' '.' 'class'; | ||
identifierSuffix: ('[' ']')+ '.' 'class'| ('[' expression ']')+| arguments | '.' 'class'| '.' explicitGenericInvocation | '.' 'this'| '.' 'super' arguments | '.' 'new' innerCreator ; | ||
creator: nonWildcardTypeArguments createdName classCreatorRest | createdName (arrayCreatorRest | classCreatorRest); | ||
createdName: classOrInterfaceType | primitiveType ; | ||
innerCreator: nonWildcardTypeArguments? Identifier classCreatorRest ; | ||
arrayCreatorRest: '[' ( ']' ('[' ']')* arrayInitializer | expression ']' ('[' expression ']')* ('[' ']')*); | ||
classCreatorRest: arguments classBody?; | ||
explicitGenericInvocation: nonWildcardTypeArguments Identifier arguments ; | ||
nonWildcardTypeArguments: '<' typeList '>'; | ||
selector: '.' Identifier arguments?| '.' 'this'| '.' 'super' superSuffix | '.' 'new' innerCreator | '[' expression ']'; | ||
superSuffix: arguments | '.' Identifier arguments?; | ||
arguments: '(' expressionList? ')'; | ||
HexLiteral: '0' ('x'|'X') HexDigit+ IntegerTypeSuffix?; | ||
IntegerTypeSuffix: ('l'|'L'); | ||
FloatTypeSuffix: ('f'|'F'|'d'|'D'); | ||
EscapeSequence: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')| UnicodeEscape | OctalEscape ; | ||
UnicodeEscape: '\\' 'u' HexDigit HexDigit HexDigit HexDigit ; | ||
ENUM: 'enum'; | ||
ASSERT: 'assert'; | ||
Identifier: Letter (Letter|JavaIDDigit)*; | ||
WS: (' '|'\r'|'\t'|'\u000C'|'\n'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters