Index

EPP が受理する Java 文法


このドキュメントは、 EPP が受理する Java 文法を、拡張 BNF 記法で 書いたものです。

plug-in は、このドキュメント中の非終端記号に新たな選択肢を追加して、 文法を拡張することができます。

実装上、非終端記号には2種類あり、拡張方法が違います。

( xxx は、非終端記号の先頭の文字を小文字にしたものです。)
メタ記号について:
・空 (<e>)
・直前の記号の0回以上の繰り返し (<*>)
・直前の記号二つの0回以上の繰り返し (<**>)
・直前の記号二つの1回以上の繰り返し (<..>)
・直前の記号二つ(A Bとする)の、A B <**> Aの形の繰り返し (<...>)



# CompUnit.java

StartTop#:
	CompilationUnit

CompilationUnit#:
	PackageDeclaration ImportDeclarations TypeDeclarations

PackageDeclaration:
	PackageDeclarationBody

PackageDeclarationBody#:
	<e>
	package name ;

ImportDeclarations:
	ImportDeclarationsBody

ImportDeclarationsBody#:
	ImportDeclaration <*>

ImportDeclaration:
	ImportDeclarationBody

ImportDeclarationBody#:
	import name .* ;
	import name ;

TypeDeclarations:
	TypeDeclarationsBody

TypeDeclarationsBody#:
	TypeDeclaraion <*>

TypeDeclaration:
	;
	TypeDeclarationOtherwise

# TypeDecl.java

Extends:
	ExtendsOtherwise

ExtendsOtherwise#:
	<e>
	extends Name , <...>

Implements:
	ImplementsOtherwise

ImplementsOtherwise#:
	implements Name , <...>

Throws:
	ThrowsOtherwise

ThrowsOtherwise#:
	throws Name , <...>

FormalParameter:
	FormarlParameterOtherwise

FormalParameterList#:
	FormalParameter , <...>

FormalParameterOtherwise#:
	Modifiers Type VariableDeclaratorId

TypeDeclarationOtherwise#:
	Modifiers ClassDeclaration

ClassDeclaration#:
	Identifier Identifier Extends Implements Throws ClassBody

ClassBody#:
	{ ClassBodyRest

ClassBodyRest#:
	ClassBodyDeclaration <*> }

ClassBodyDeclaration:
	StaticInitializer
	Block
	;
	Modifier ClassBodyDeclarationAfterModifiers

StaticInitializer#:
	static Block

ClassBodyDeclarationAfterModifiers#:
	ClassDeclaration
	ConstructorDeclaration
	MethodOrFieldDeclaration

ConstructorDeclaration#:
	Identifier ( FormalParameterList ) Throws Block

MethodOrFieldDeclaration#:
	Type MethodDeclaration
	Type FieldDeclaration

MethodDeclaration#:
	Identifier ( FormalParameterList ) [ ] <**> Throws Statement
	Identifier ( FormalParameterList ) [ ] <**> Throws Block

FieldDeclaration#:
	VariableDeclarators ;

# Statement.java

Statement:
	Block
	;
	switch ( Expression ) Block
	case Expression :
	default :
	do Statement while ( Expression ) ;
	break ;
	break Identifier ;
	continue ;
	continue Identifier ;
	return ;
	return Expression ;
	synchronized ( Expression ) Block
	throw Expression ;
	try Block CatchClause <*> FinallyClause_opt
	if ( Expression ) Statement else Statement
	if ( Expression ) Statement
	while ( Expression ) Statement
	for ( Statement Expression_opt ; Expression_opt ) Statement
	StatementOtherwise

StatementOtherwise#:
	Expression ;
	Expression :			# Expressionがidでない場合はエラー
	LocalVariableDecl

Block:
	BlockOtherwise

BlockOtherwise#:
	{ BlockRest

BlockRest#:
	Statement <*> }

CatchClause#:
	catch ( FormalParameter ) Block

FinallyClause#:
	finally Block

Modifiers:
	ModifiersOtherwise

Modifier:
	<e>
	public protected private static abstract final
		native synchronized transient volatile

LocalVariableDecl#:
	Modifiers ClassDeclaration
	Modifiers Type VariableDeclarators ;

ModifiersOtherwise#:
	Modifier <*>

VariableDeclarators#:
	variableDeclarator , <...>

VariableDeclarator#:
	VariableDeclaratorId
	VariableDeclaratorId = VariableInitializer

VariableDeclaratorId:
	Identifer
	VariableDeclaratorId [ ]

VariableInitializer#:
	ArrayInitializer
	ExpressionNoComma

ArrayInitializer#:
	{ , }
	{ }
	{ VariableIntializer , <...> , }
	{ VariableIntializer , <...> }

# Exp.java, ExpNonTerm.java

Primary:
	Literal
	this ( ArgumentList )
	this
	super ( ArgumentList )
	super . Identifier ( ArgumentList )
	super . Identifier
	( Expression ) unaryExpression		# Expressionが基本型である場合
	( Expression ) unaryExpressionNotPlusMinus # Expressionが型の場合
	( Expression )
	InstanceCreation
	Primary . InstanceCreation
	Primary . class
	Primary . Identifier ( ArgumentList )
	Primary . Identifier
	Primary [ ]
	Primary [ Expression ]
	PrimaryOtherwise

Type#:
	Primary

InstanceCreation#:
	new Name ( ArgumentList ) ClassBody
	new Name ( ArgumentList )
	new Name ArrayCreation

ArrayCreation#:
	[ ] ArrayInitializer_opt
	[ Expression ] ArrayInitializer_opt

PostfixExpression:
	PostfixExpression ++
	PostfixExpression --
	Primary

UnaryExpressionNotPlusMinus:
	‾ UnaryExpression
	! UnaryExpression
	PostfixExpression

UnaryExpression:
	++ UnaryExpression
	-- UnaryExpression
	+ UnaryExpression
	- UnaryExpression
	UnaryExpressionNotPlusMinus

MemberSectionExpression:
	MemberSectionExpression .* UnaryExpression
	UnaryExpression

MultipicativeExpression:
	MultiplicativeExpression * MemberSectionExpression
	MultiplicativeExpression / MemberSectionExpression
	MultiplicativeExpression % MemberSectionExpression
	MemberSectionExpression

AdditiveExpression:
	AdditiveExpression + MultiplicativeExpression
	AdditiveExpression - MultiplicativeExpression
	MultiplicativeExpresson

ShiftExpression:
	ShiftExpression << AdditiveExpression
	ShiftExpression >> AdditiveExpression
	ShiftExpression >>> AdditiveExpression
	AdditiveExpression

RelationalExpression:
	RelationalExpression < ShiftExpression
	RelationalExpression > ShiftExpression
	RelationalExpression <= ShiftExpression
	RelationalExpression >= ShiftExpression
	RelationalExpression instanceof ShiftExpression
	ShiftExpression

EqualityExpression:
	EqualitExpression == RelationalExpression
	EqualitExpression != RelationalExpression
	RelationalExpression

AndExpression:
	AndExpression & EqualitiExpression
	EqualityExpression

ExclusiveOrExpression:
	ExclusiveOrExpression ^ AndExpression
	AndExpression

InclusiveOrExpression:
	InclusiveOrExpression | ExclusiveOrExpression
	ExclusiveOrExpression

ConditionalAndExpression:
	ConditionalAndExpression && InclusiveOrExpression
	InclusiveOrExpression

ConditionalOrExpression:
	ConditinalOrExpression || ConditionalAndExpression
	ConditionalAndExpression

ConditionalExpression:
	ConditionalOrExpression ? Expression : ConditionalExpression
	ConditionalOrExpression

AssignmentExpression:
	ConditionalExpression = AssignmentExpression
	ConditionalExpression *= AssignmentExpression
	ConditionalExpression /= AssignmentExpression
	ConditionalExpression %= AssignmentExpression
	ConditionalExpression += AssignmentExpression
	ConditionalExpression -= AssignmentExpression
	ConditionalExpression <<= AssignmentExpression
	ConditionalExpression >>= AssignmentExpression
	ConditionalExpression >>>= AssignmentExpression
	ConditionalExpression &= AssignmentExpression
	ConditionalExpression ^= AssignmentExpression
	ConditionalExpression |= AssignmentExpression
	ConditionalExpression

ExpressionNoComma:
	AssignmentExpression

CommaExpression:
	CommaExpression , ExpressionNoComma
	ExpressionNoComma

Expression:
	CommaExpression

Name#:
	Identifier . <...>

PrimaryOtherwise#:
	Identifier . <..> InstanceCreation
	Identifier . <..> class
	Identifier ( ArgumentList )
	Identifier
	Identifier . <...> ( ArgumentList )
	Identifier . <...>

Argument:
	ExpressionNoComma

ArgumentList#:
	Argument , <...>



Index