Skip to content
Snippets Groups Projects
Select Git revision
  • 703f8a95c1cc0532fc0148df5c3f3105f76e0637
  • develop default protected
  • support-for-intellij-25.1
  • chore/support-for-intellijj-2024.3
  • feature/references
  • feature/commenter-for-aspect-files
  • feature/link-generated-code-and-definition
  • main
  • legacy
  • v0.3.5 protected
  • v0.3.4 protected
  • v0.3.3 protected
  • v0.3.2 protected
  • v0.3.1 protected
  • v0.3.0 protected
  • v0.2.0 protected
16 results

Aspect.bnf

Blame
  • Aspect.bnf 19.77 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.AspectTypes"
      elementTypeClass="org.jastadd.tooling.aspect.psi.AspectElementType"
      tokenTypeClass="org.jastadd.tooling.aspect.psi.AspectTokenType"
    
      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)'
          ]
    }
    
    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 | annotation)*
    
    type_declaration ::= SEMICOLON | (modifiers ( class_declaration | interface_declaration | unmodified_enum_declaration | annotation_type_declaration | aspect_declaration ) )
    
    aspect_declaration ::= ASPECT aspect_name aspect_body
    {
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectDeclarationImplExtension"
      implements="org.jastadd.tooling.common.psi.NamedElement"
    }
    
    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_body_declarations_eof omitted because they cannot be parsed
    
    // simplified, because syntax is exactly the same as normal class declaration
    aspect_class_declaration ::= modifiers class_declaration
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
    }
    
    // aspect_class_body unused
    
    aspect_interface_declaration ::= modifiers INTERFACE simple_type_name 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 parameter_name (COMMA type parameter_name)* )? RPAREN (CIRCULAR LBRACKET expression RBRACKET)? SEMICOLON
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectSynAttributeDeclarationImplExtension"
    }
    
    aspect_interface_inh_attribute_declaration ::= annotation* INH LAZY? FINAL? aspect_type attribute_name LPAREN (type parameter_name (COMMA type parameter_name)* )? RPAREN (CIRCULAR LBRACKET expression RBRACKET)? SEMICOLON
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectInhAttributeDeclarationImplExtension"
    }
    
    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
    
    // TODO check if simplification is okay
    aspect_nested_interface_declaration ::= modifiers interface_declaration
    
    // TODO check if simplification is okay
    aspect_nested_class_declaration ::= modifiers class_declaration
    
    aspect_method_declaration ::= modifiers type_parameters? aspect_result_type ast_type_name DOT method_declarator (THROWS name_list)? (block | SEMICOLON)
    
    aspect_refine_method_declaration ::= REFINE [aspect_name] modifiers type_parameters? aspect_result_type ast_type_name DOT method_declarator (THROWS name_list)? (block | SEMICOLON)
    
    aspect_constructor_declaration ::= modifiers ast_type_name DOT ast_type_name formal_parameters (THROWS name_list)? LBRACE explicit_constructor_invocation? block_statement* RBRACE
    
    aspect_refine_constructor_declaration ::= REFINE aspect_name (PUBLIC | PROTECTED | PRIVATE) ast_type_name DOT method_name formal_parameters (THROWS name_list)? LBRACE block_statement* RBRACE
    
    aspect_field_declaration ::= modifiers aspect_type ast_type_name DOT variable_declarator (COMMA variable_declarator)* SEMICOLON
    
    aspect_syn_attribute_declaration ::= annotation* SYN NTA? LAZY? FINAL? aspect_type ast_type_name DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)* )? RPAREN (CIRCULAR LBRACKET expression RBRACKET)? ( ASSIGN expression SEMICOLON | block | SEMICOLON )
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectSynAttributeDeclarationImplExtension"
    }
    
    aspect_inh_attribute_declaration ::= annotation* INH NTA? LAZY? FINAL? aspect_type ast_type_name DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)* )? RPAREN (CIRCULAR LBRACKET expression RBRACKET)? SEMICOLON
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAspectInhAttributeDeclarationImplExtension"
    }
    
    // FIXME parentheses are not required around the WHEN expression?
    aspect_rewrite ::= REWRITE aspect_name (ast_type_name DOT method_name LPAREN RPAREN)? LBRACE ((WHEN LPAREN expression RPAREN)? TO aspect_type ( expression SEMICOLON | block ))+ RBRACE
    
    aspect_syn_equation ::= annotation* EQUATION ast_type_name DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)*)? RPAREN ( ASSIGN expression SEMICOLON | block )
    
    aspect_refine_syn_equation ::= REFINE aspect_name EQUATION ast_type_name DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)*)? RPAREN (ASSIGN expression SEMICOLON | block)
    
    aspect_inh_equation ::= annotation* EQUATION ast_type_name DOT attribute_name LPAREN (INT parameter_name)? RPAREN DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)*)? RPAREN (ASSIGN expression SEMICOLON | block)
    
    aspect_refine_inh_equation ::= REFINE aspect_name EQUATION ast_type_name DOT attribute_name LPAREN (INT parameter_name)? RPAREN DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)*)? RPAREN (ASSIGN expression SEMICOLON | block)
    
    collection_attribute ::= annotation* COLL aspect_type ast_type_name DOT attribute_name LPAREN RPAREN CIRCULAR? (LBRACKET expression RBRACKET)? (WITH method_name)? (ROOT ast_type_name)? SEMICOLON
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectCollectionAttributeImplExtension"
    }
    
    collection_contribution ::= annotation* ast_type_name CONTRIBUTES ( NTA expression TO ast_type_name DOT attribute_name LPAREN RPAREN | EACH? expression (WHEN expression)? TO ast_type_name DOT attribute_name LPAREN RPAREN (FOR  EACH? expression)? | block TO ast_type_name DOT attribute_name LPAREN RPAREN ) SEMICOLON
    
    aspect_add_interface ::= ast_type_name IMPLEMENTS type_name_list SEMICOLON
    
    aspect_extend_interface ::= ast_type_name EXTENDS type_name_list SEMICOLON
    
    class_declaration ::= CLASS simple_type_name type_parameters? (EXTENDS class_or_interface_type)? (implements type_name_list)? class_body
    
    type_name_list ::= class_or_interface_type (COMMA class_or_interface_type)*
    
    unmodified_class_declaration ::= CLASS simple_type_name type_parameters? (EXTENDS class_or_interface_type)? (IMPLEMENTS type_name_list)? class_body
    
    // TODO check simplification
    aspect_enum_declaration ::= modifiers ENUM simple_type_name (IMPLEMENTS type_name_list)? enum_body
    
    unmodified_enum_declaration ::= ENUM java_identifier (IMPLEMENTS type_name_list)? enum_body
    
    enum_body ::= LBRACE enum_constant (COMMA enum_constant)* (SEMICOLON class_body_declaration*)? RBRACE
    
    enum_constant ::= java_identifier arguments? class_body?
    
    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)*
    
    class_body ::= LBRACE class_body_declaration* RBRACE
    
    class_body_declaration ::= initializer | modifiers ( unmodified_class_declaration | unmodified_interface_declaration | annotation_type_declaration | unmodified_enum_declaration | constructor_declaration | field_declaration | method_declaration ) | SEMICOLON
    
    interface_declaration ::= unmodified_interface_declaration
    
    unmodified_interface_declaration ::= INTERFACE simple_type_name type_parameters? (EXTENDS type_name_list)? LBRACE interface_member_declaration* RBRACE
    
    interface_member_declaration ::= modifiers (unmodified_class_declaration | unmodified_interface_declaration | field_declaration | method_declaration) | SEMICOLON
    
    field_declaration ::= aspect_type variable_declarator (COMMA variable_declarator)* SEMICOLON
    
    variable_declarator ::= variable_declarator_id ( ASSIGN variable_initializer )?
    
    variable_declarator_id ::= java_identifier ( LBRACKET RBRACKET )*
    
    variable_initializer ::= array_initializer | expression
    
    array_initializer ::= LBRACE ( variable_initializer (COMMA variable_initializer)* )? RBRACE
    
    method_declaration ::= type_parameters? aspect_result_type method_declarator (THROWS name_list)? (block | SEMICOLON)
    
    method_declarator ::= java_identifier formal_parameters (LBRACKET RBRACKET)*
    
    formal_parameters ::= LPAREN ( formal_parameter ( COMMA formal_parameter )* )? RPAREN
    
    formal_parameter ::= FINAL? type DOTS? variable_declarator_id
    
    constructor_declaration ::= type_parameters? java_identifier formal_parameters (THROWS name_list)? LBRACE explicit_constructor_invocation? block_statement* RBRACE
    
    explicit_constructor_invocation ::= (THIS | SUPER) arguments SEMICOLON
    
    initializer ::= STATIC? block
    
    // Attribute type names can not start with JastAdd reserved words such as 'syn', 'eq', etc.
    aspect_type ::= aspect_reference_type | ( primitive_type (LBRACKET RBRACKET)? )
    
    aspect_result_type ::= VOID | aspect_type
    
    aspect_reference_type ::= aspect_class_or_interface_type (LBRACKET RBRACKET)*
    
    aspect_class_or_interface_type ::= ast_type_name 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? )*
    {
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectClassOrInterfaceTypeImplExtension"
      implements="org.jastadd.tooling.common.psi.NamedElement"
    }
    
    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)? )
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
    }
    
    assignment_operator ::= ASSIGN | STARASSIGN | SLASHASSIGN | REMASSIGN | PLUSASSIGN | MINUSASSIGN | LSHIFTASSIGN | RSIGNEDSHIFTASSIGN | RUNSIGNEDSHIFTASSIGN | ANDASSIGN | XORASSIGN | ORASSIGN
    
    conditional_expression ::= conditional_or_expression ( QUESTIONMARK expression COLON conditional_expression)?
    
    conditional_or_expression ::= conditional_and_expression ( SC_OR conditional_and_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)*
    
    // member_selector unused!
    
    primary_prefix ::= literal | THIS | (SUPER (DOT java_identifier)?) | (LPAREN expression RPAREN) | allocation_expression | (result_type DOT CLASS) | type | name_name
    
    primary_suffix ::= (DOT THIS) | (DOT allocation_expression) | (DOT type_arguments java_identifier) | (LBRACKET expression RBRACKET) | (DOT java_identifier) | arguments | DOUBLECOLON type_arguments? (NEW | 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)*
    
    statement ::= labeled_statement | assert_statement | block | empty_statement | statement_expression SEMICOLON | switch_statement | if_statement | while_statement | do_statement | for_statement | break_statement | continue_statement | return_statement | throw_statement | synchronized_statement | try_statement
    
    assert_statement ::= ASSERT expression ( COLON expression )? SEMICOLON
    
    labeled_statement ::= java_identifier COLON statement
    
    block ::= LBRACE block_statement* RBRACE
    {
      implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
    }
    
    // TODO | UnmodifiedClassDeclaration("")
    block_statement ::= (local_variable_declaration SEMICOLON) | statement
    
    local_variable_declaration ::= FINAL? type variable_declarator (COMMA variable_declarator)*
    
    empty_statement ::= SEMICOLON
    
    statement_expression ::= pre_increment_expression | pre_decrement_expression | ( primary_expression ( INCR | DECR | assignment_operator expression )? )
    
    switch_statement ::= SWITCH LPAREN expression RPAREN LBRACE ( switch_label block_statement* )* RBRACE
    
    switch_label ::= CASE expression COLON | DEFAULT COLON
    
    if_statement ::= IF LPAREN expression RPAREN statement ( ELSE statement )?
    
    while_statement ::= WHILE LPAREN expression RPAREN statement
    
    do_statement ::= DO statement WHILE LPAREN expression RPAREN SEMICOLON
    
    for_statement ::= FOR LPAREN ( type java_identifier COLON expression | for_init? SEMICOLON expression? SEMICOLON for_update? ) RPAREN statement
    
    for_init ::= local_variable_declaration | statement_expression_list
    
    statement_expression_list ::= statement_expression ( COMMA statement_expression )*
    
    for_update ::= statement_expression_list
    
    break_statement ::= BREAK java_identifier? SEMICOLON
    
    continue_statement ::= CONTINUE java_identifier? SEMICOLON
    
    return_statement ::= RETURN expression? SEMICOLON
    
    throw_statement ::= THROW expression SEMICOLON
    
    synchronized_statement ::= SYNCHRONIZED LPAREN expression RPAREN block
    
    try_statement ::= TRY ( LPAREN local_variable_declaration ( SEMICOLON local_variable_declaration )* SEMICOLON? RPAREN )? block ( CATCH LPAREN FINAL? type ( BIT_OR FINAL type )* variable_declarator_id RPAREN block )* ( FINALLY block )?
    
    // TODO maybe change order!
    annotation ::= ( normal_annotation | single_member_annotation | marker_annotation )
    
    normal_annotation ::= AT name_name LPAREN member_value_pairs? RPAREN
    
    marker_annotation ::= AT name_name
    
    single_member_annotation ::= AT name_name LPAREN member_value RPAREN
    
    member_value_pairs ::= member_value_pair (COMMA member_value_pair)*
    
    member_value_pair ::= java_identifier ASSIGN member_value
    
    member_value ::= annotation | member_value_array_initializer | conditional_expression
    
    member_value_array_initializer ::= LBRACE member_value ( COMMA  member_value )* COMMA? RBRACE
    
    annotation_type_declaration ::= AT INTERFACE java_identifier annotation_type_body
    
    annotation_type_body ::= LBRACE annotation_type_member_declaration* RBRACE
    
    annotation_type_member_declaration ::= ( modifiers (aspect_type java_identifier LPAREN RPAREN default_value? SEMICOLON | unmodified_class_declaration | unmodified_interface_declaration | unmodified_enum_declaration | annotation_type_declaration | field_declaration ) ) | SEMICOLON
    
    default_value ::= DEFAULT member_value
    
    aspect_cache_declaration ::= (CACHE | UNCACHE) aspect_name DOT attribute_name LPAREN (type parameter_name? (COMMA type parameter_name?)* )? RPAREN SEMICOLON
    
    java_identifier ::= IDENTIFIER | INH | SYN | LAZY | REWRITE | TO | WHEN | ASPECT | EQUATION | CIRCULAR | REFINE | COLL | CONTRIBUTES | EACH | NTA | CACHE | UNCACHE
    
    attribute_name ::= IDENTIFIER
    
    ast_type_name ::= IDENTIFIER
    {
      extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectAstTypeNameImplExtension"
      implements="org.jastadd.tooling.common.psi.NamedElement"
    }
    
    aspect_name ::= IDENTIFIER
    
    simple_type_name ::= IDENTIFIER
    
    parameter_name ::= IDENTIFIER
    
    method_name ::= IDENTIFIER
    
    // unused keywords must still appear somewhere
    unused_keywords ::= GOTO | CONST ELLIPSIS | PACKAGE