Select Git revision
JastAddAspect.bnf

Johannes Mey authored
JastAddAspect.bnf 14.58 KiB
{
parserClass="org.jastadd.tooling.aspect.parser.JastAddAspectParser"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="JastAddAspect"
psiImplClassSuffix="Impl"
psiPackage="org.jastadd.tooling.aspect.psi"
psiImplPackage="org.jastadd.tooling.aspect.psi.impl"
elementTypeHolderClass="org.jastadd.tooling.aspect.psi.JastAddAspectTypes"
elementTypeClass="org.jastadd.tooling.aspect.JastAddAspectElementType"
tokenTypeClass="org.jastadd.tooling.aspect.JastAddAspectTokenType"
tokens = [
WhiteSpace = 'regexp:[ \t\n\r\f]'
SingleLineComment = 'regexp:[/][/] [^\n\r]* (\n | \r | \r\n)'
FormalComment = 'regexp:[/][*][*] [^*]* [*]+([^*/][^*]*[*]+)*[/]'
MultiLineComment = 'regexp:[/][*] [^*]+ [*]+([^*/][^*]*[*]+)*[/]'
NotParenthesis = 'regexp:[^{}]+'
MULTI_LINE_COMMENT = 'regexp:[/][*] [^*]+ [*]+([^*/][^*]*[*]+)*[/]'
FORMAL_COMMENT = 'regexp:[/][*][*] [^*]* [*]+([^*/][^*]*[*]+)*[/]'
SINGLE_LINE_COMMENT = 'regexp:[/][/] [^\n\r]* (\n | \r | \r\n)'
]
}
//attribute_equation ::= EQ java_block
//
//java_block ::= JAVABLOCK
//{
// implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaBlockExtension"
// extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaBlockImplExtension"
//}
// aspect_body_declarations_eof ::= aspect_body_declaration* EOF
//jastaddAspectFile ::= ( aspect_declaration | comment )*
//
//comment ::= (MULTI_LINE_COMMENT | DOC_COMMENT | SINGLE_LINE_COMMENT)
compilation_unit ::= import_declaration* type_declaration*
import_declaration ::= IMPORT STATIC? name_name (DOT STAR)? SEMICOLON
modifiers ::= (PUBLIC | STATIC | PROTECTED | PRIVATE | FINAL | ABSTRACT | SYNCHRONIZED | NATIVE | TRANSIENT | VOLATILE | STRICTFP)*
type_declaration ::= SEMICOLON | (modifiers ( class_declaration | interface_declaration | enum_declaration | annotation_type_declaration | aspect_declaration ) )
aspect_declaration ::= ASPECT IDENTIFIER aspect_body
aspect_body ::= LBRACE aspect_body_declaration* RBRACE
aspect_body_declaration ::= ( aspect_refine_inh_equation
| aspect_refine_syn_equation
| aspect_refine_method_declaration
| aspect_refine_constructor_declaration
| aspect_class_declaration
| aspect_interface_declaration
| aspect_enum_declaration
| aspect_syn_attribute_declaration
| aspect_inh_attribute_declaration
| aspect_rewrite
| aspect_inh_equation
| aspect_syn_equation
| aspect_add_interface
| aspect_extend_interface
| collection_attribute
| collection_contribution
| aspect_method_declaration
| aspect_constructor_declaration
| aspect_field_declaration
| aspect_cache_declaration )
aspect_class_declaration ::= modifiers class_declaration
aspect_interface_declaration ::= modifiers INTERFACE IDENTIFIER type_parameters? (EXTENDS type_name_list)? LBRACE aspect_interface_member_declaration* RBRACE
aspect_interface_member_declaration ::= ( aspect_nested_class_declaration
| aspect_nested_interface_declaration
| aspect_interface_syn_attribute_declaration
| aspect_interface_inh_attribute_declaration
| aspect_interface_method_declaration
| aspect_interface_field_declaration )
aspect_interface_syn_attribute_declaration ::= annotation* SYN LAZY? FINAL? aspect_type attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? SEMICOLON
aspect_interface_inh_attribute_declaration ::= annotation* INH LAZY? FINAL? aspect_type attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? SEMICOLON
aspect_interface_method_declaration ::= (PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED )* aspect_result_type method_declarator (THROWS name_list ) SEMICOLON
aspect_interface_field_declaration ::= modifiers aspect_type variable_declarator (COMMA variable_declarator)* SEMICOLON
aspect_nested_interface_declaration ::= modifiers interface_declaration
aspect_nested_class_declaration ::= modifiers class_declaration
aspect_method_declaration ::= modifiers type_parameters? aspect_result_type IDENTIFIER DOT method_declarator (THROWS name_list)? (block | SEMICOLON)
aspect_refine_method_declaration ::= REFINE [IDENTIFIER] modifers type_parameters? aspect_result_type IDENTIFIER DOT method_declarator (THROWS name_list)? (block | SEMICOLON)
aspect_constructor_declaration ::= modifiers IDENTIFIER DOT IDENTIFIER formal_parameters (THROWS name_list)? LBRACE JAVA_EXPLICIT_CONSTRUCTUR_BLOCK RBRACE
aspect_refine_constructor_declaration ::= REFINE IDENTIFIER (PUBLIC | PROTECTED | PRIVATE) IDENTIFIER DOT IDENTIFIER formal_parameters (THROWS name_list)? LBRACE block_statement* RBRACE
aspect_field_declaration ::= modifiers aspect_type IDENTIFIER DOT variable_declarator (COMMA variable_declarator)* SEMICOLON
aspect_syn_attribute_declaration ::= annotation* SYN NTA? LAZY? FINAL? aspect_type IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? ( ASSIGN expression SEMICOLON | block | SEMICOLON )
aspect_inh_attribute_declaration ::= annotation* INH NTA? LAZY? FINAL? aspect_type IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? (CIRCULAR expression_in_brackets)? SEMICOLON
aspect_rewrite ::= REWRITE IDENTIFIER (IDENTIFIER DOT IDENTIFIER LPAREN RPAREN)? LBRACE ((WHEN LPAREN expression RPAREN)? TO aspect_type ( expression SEMICOLON | block ))+ RBRACE
aspect_syn_equation ::= annotation* EQUATION IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)*)? RPAREN ( ASSIGN expression SEMICOLON | block )
aspect_refine_syn_equation ::= REFINE IDENTIFIER EQUATION IDENTIFIER attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)*)? RPAREN (ASSIGN expression SEMICOLON | block)
aspect_inh_equation ::= annotation* EQUATION IDENTIFIER DOT IDENTIFIER LPAREN (INT IDENTIFIER)? DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)*)? RPAREN (ASSIGN expression | block)
aspect_refine_inh_equation ::= REFINE IDENTIFIER EQUATION IDENTIFIER DOT IDENTIFIER LPAREN (INT IDENTIFIER)? RPAREN DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)*)? RPAREN (ASSIGN expression | block)
collection_attribute ::= annotation* COLL aspect_type IDENTIFIER DOT attribute_name LPAREN RPAREN CIRCULAR? (expression_in_brackets)? (WITH IDENTIFIER)? (ROOT IDENTIFIER)? SEMICOLON
collection_contribution ::= annotation* CONTRIBUTES ( NTA expression TO IDENTIFIER DOT attribute_name LPAREN RPAREN | EACH? expression (WHEN expression)? TO IDENTIFIER DOT attribute_name LPAREN RPAREN (FOR EACH? expression)? | block TO IDENTIFIER DOT attribute_name LPAREN RPAREN ) SEMICOLON
aspect_add_interface ::= IO IMPLEMENTS type_name_list SEMICOLON
aspect_extend_interface ::= IDENTIFIER EXTENDS type_name_list SEMICOLON
// added
type_name_list ::= class_or_interface_type (COMMA class_or_interface_type)*
attribute_name ::= IDENTIFIER
// TODO | UnmodifiedClassDeclaration("")
block_statement ::= (FINAL? type java_identifier local_variable_declaration SEMICOLON) | statement
aspect_cache_declaration ::= (CACHE | UNCACHE) IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER? (type IDENTIFIER?)* )? RPAREN SEMICOLON
java_identifier ::= IDENTIFIER | INH | SYN | LAZY | REWRITE | TO | WHEN | ASPECT | EQUATION | CIRCULAR | REFINE | COLL | CONTRIBUTES | EACH | NTA | CACHE | UNCACHE
// Attribute type names can not start with JastAdd reserved words such as 'syn', 'eq', etc.
aspect_type ::= aspect_reference_type | ( primitive_type (LBRACKET RBRACKET)? )
formal_parameters ::= LPAREN ( formal_parameter ( COMMA formal_parameter )* )? RPAREN
formal_parameter ::= FINAL? type DOTS? variable_declarator_id
variable_declarator_id ::= java_identifier ( LBRACKET RBRACKET )*
aspect_enum_declaration ::= modifiers enum_declaration
variable_declarator ::= variable_declarator_id ( ASSIGN variable_initializer )?
variable_initializer ::= array_initializer | expression
array_initializer ::= LBRACE ( variable_initializer (COMMA variable_initializer)* )? RBRACE
aspect_reference_type ::= aspect_class_or_interface_type (LBRACKET RBRACKET)*
aspect_class_or_interface_type ::= IDENTIFIER type_arguments? (DOT java_identifier type_arguments? )*
type ::= reference_type | primitive_type
reference_type ::= ( primitive_type (LBRACKET RBRACKET)+ ) | ( class_or_interface_type (LBRACKET RBRACKET)* )
class_or_interface_type ::= java_identifier type_arguments? (DOT java_identifier type_arguments? )*
type_arguments ::= LT (type_argument (COMMA type_argument)* )? GT
type_argument ::= reference_type | (QUESTIONMARK wildcard_bounds?)
wildcard_bounds ::= (EXTENDS reference_type) | SUPER reference_type
primitive_type ::= boolean | char | byte | short | int | long | float | double
result_type ::= VOID | type
name_name ::= java_identifier (DOT java_identifier)*
name_list ::= name_name (COMMA name_name)*
expression ::= lambda_expression | ( conditional_expression (assignment_operator expression)? )
assignment_operator ::= ASSIGN | STARASSIGN | SLASHASSIGN | REMASSIGN | PLUSASSIGN | MINUSASSIGN | LSHIFTASSIGN | RSIGNEDSHIFTASSIGN | RUNSIGNEDSHIFTASSIGN | ANDASSIGN | XORASSIGN | ORASSIGN
conditional_expression ::= conditional_or_expression ( HOOK expression COLON conditional_expression)?
conditional_or_expression ::= conditional_and_expression ( SC_OR expression COLON conditional_expression )*
conditional_and_expression ::= inclusive_or_expression ( SC_AND inclusive_or_expression )*
inclusive_or_expression ::= exclusive_or_expression ( BIT_OR exclusive_or_expression )*
exclusive_or_expression ::= and_expression ( XOR and_expression )*
and_expression ::= equality_expression ( BIT_AND equality_expression )*
equality_expression ::= instance_of_expression ( (EQ | NE) instance_of_expression )*
instance_of_expression ::= relational_expression ( INSTANCEOF type )?
relational_expression ::= shift_expression ( (LT | GT | LE | GE) shift_expression )*
shift_expression ::= additive_expression ( ( (LSHIFT) | (GT GT GT?) ) additive_expression )*
additive_expression ::= multiplicative_expression ( (PLUS | MINUS) multiplicative_expression )*
multiplicative_expression ::= unary_expression ( (STAR | SLASH | REM) unary_expression )*
unary_expression ::= ( (PLUS | MINUS) unary_expression ) | pre_increment_expression | pre_decrement_expression | unary_expression_not_plus_minus
pre_increment_expression ::= INCR primary_expression
pre_decrement_expression ::= DECR primary_expression
unary_expression_not_plus_minus ::= ( (TILDE | BANG) unary_expression ) | cast_expression | postfix_expression
postfix_expression ::= primary_expression (INCR | DECR)?
cast_expression ::= LPAREN type RPAREN unary_expression_not_plus_minus
primary_expression ::= primary_prefix (primary_suffix)*
primary_prefix ::= literal | THIS | (SUPER DOT java_identifier) | (LPAREN expression RPAREN) | allocation_expression | (result_type DOT_CLASS) | name_name
primary_suffix ::= (DOT THIS) | (DOT allocation_expression) | (DOT type_arguments java_identifier) | (LBRACKET expression RBRACKET) | (DOT java_identifier) | arguments | DOUBLECOLON NEW | DOUBLECOLON java_identifier
literal ::= INTEGER_LITERAL | FLOATING_POINT_LITERAL | CHARACTER_LITERAL | STRING_LITERAL | boolean_literal | null_literal
boolean_literal ::= TRUE | FALSE
null_literal ::= NULL
arguments ::= LPAREN argument_list RPAREN
argument_list ::= expression (COMMA expression)*
allocation_expression ::= ( NEW primitive_type array_dims_and_inits ) | (NEW class_or_interface_type type_arguments? (array_dims_and_inits | (arguments class_body?)) )
array_dims_and_inits ::= ( (LBRACKET expression RBRACKET)+ (LBRACKET RBRACKET)* ) | ( (LBRACKET RBRACKET)+ array_initializer )
lambda_expression ::= lambda_parameters ARROW ( expression | block )
lambda_parameters ::= name_name | (LPAREN (typed_lambda_parameter | untyped_lambda_parameter)? RPAREN)
typed_lambda_parameter ::= type name_name (COMMA type name_name)*
untyped_lambda_parameter ::= name_name (COMMA name_name)*
local_variable_declaration ::= FINAL? type variable_declarator (COMMA variable_declarator)*
type_parameters ::= LT type_parameter (COMMA type_parameter)* GT
type_parameter ::= java_identifier type_bound?
type_bound ::= EXTENDS class_or_interface_type (AMPERSAND class_or_interface_type)*
aspect_result_type ::= VOID | aspect_type
method_declarator ::= java_identifier formal_parameters (LBRACKET RBRACKET)*
// TODO maybe change order!
annotation ::= ( normal_annotation | single_member_annotation | marker_annotation )
// island things
//class_body_declaration_in_paren ::= JAVA_IN_PAREN
//{
// implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaBlockExtension"
// extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaBlockImplExtension"
//}
// should be parsed after circular and in collection attributes
expression_in_brackets ::= LBRACKET_ANYTHING_RBRACKET // LBRACKET expression RBRACKET
// at symbol only in these rules
marker_annotation ::= AT_NAME
normal_annotation ::= AT_NAME_LPAREN_ANYTHING_RPAREN // TODO!
single_member_annotation ::= AT_NAME_LPAREN_ANYTHING_RPAREN // TODO!
annotation_type_declaration ::= AT_INTERFACE_ANYTHING_LBRACE_ANYTHING_RBRACE // AT INTERFACE java_indentifier LBRACE annotation_type_member_declaration RBRACE
// previous token must not be DOT!
class_declaration ::= CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE // CLASS IDENTIFIER (EXTENDS class_or_type_interface)? (implements type_name_list)? LBRACE class_body_declaration RBRACE
// must not be directly in an aspect, but can be in a class or interface (or enum?) in an aspect
interface_declaration ::= INTERFACE_ANYTHING_LBRACE_ANYTHING_RBRACE // INTERFACE java_indentifier LBRACE interface_member_declaration RBRACE
// can be anywhere
enum_declaration ::= ENUM_ANYTHING_LBRACE_ANYTHING_RBRACE // ENUM java_identifier (implements type_name_list)? LBRACE enum_constant (COMMA enum_constant)* (SEMICOLON class_body_declaration* )? RBRACE
// only within attribute equations
block ::= LBRACE_ANYTHING_RBRACE
// TODO unsupported
class_body ::= CLASS_BODY_UNSUPPORTED