Skip to content
Snippets Groups Projects
Commit f43460b2 authored by Johannes Mey's avatar Johannes Mey
Browse files

some grammar and lexer fixes and an interface for attribute PSI elements

parent ac408667
No related branches found
No related tags found
No related merge requests found
...@@ -89,8 +89,16 @@ aspect_interface_member_declaration ::= ( aspect_nested_class_declaration ...@@ -89,8 +89,16 @@ aspect_interface_member_declaration ::= ( aspect_nested_class_declaration
| aspect_interface_field_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_syn_attribute_declaration ::= annotation* SYN LAZY? FINAL? aspect_type attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectSynAttributeImpl"
}
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_inh_attribute_declaration ::= annotation* INH LAZY? FINAL? aspect_type attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectInhAttributeImpl"
}
aspect_interface_method_declaration ::= (PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED )* aspect_result_type method_declarator (THROWS name_list ) SEMICOLON aspect_interface_method_declaration ::= (PUBLIC | PROTECTED | PRIVATE | STATIC | ABSTRACT | FINAL | NATIVE | SYNCHRONIZED )* aspect_result_type method_declarator (THROWS name_list ) SEMICOLON
...@@ -111,22 +119,35 @@ aspect_refine_constructor_declaration ::= REFINE IDENTIFIER (PUBLIC | PROTECTED ...@@ -111,22 +119,35 @@ aspect_refine_constructor_declaration ::= REFINE IDENTIFIER (PUBLIC | PROTECTED
aspect_field_declaration ::= modifiers aspect_type IDENTIFIER DOT variable_declarator (COMMA variable_declarator)* SEMICOLON 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_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 )
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectSynAttributeImpl"
}
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_inh_attribute_declaration ::= annotation* INH NTA? LAZY? FINAL? aspect_type IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR expression_in_brackets)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectInhAttributeImpl"
}
// FIXME parentheses are not required around the WHEN expression?
aspect_rewrite ::= REWRITE IDENTIFIER (IDENTIFIER DOT IDENTIFIER LPAREN RPAREN)? LBRACE ((WHEN LPAREN expression RPAREN)? TO aspect_type ( expression SEMICOLON | block ))+ RBRACE 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_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_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_inh_equation ::= annotation* EQUATION IDENTIFIER DOT IDENTIFIER LPAREN (INT IDENTIFIER)? RPAREN DOT attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)*)? RPAREN (ASSIGN expression SEMICOLON | 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) 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 SEMICOLON | block)
collection_attribute ::= annotation* COLL aspect_type IDENTIFIER DOT attribute_name LPAREN RPAREN CIRCULAR? (expression_in_brackets)? (WITH IDENTIFIER)? (ROOT IDENTIFIER)? SEMICOLON collection_attribute ::= annotation* COLL aspect_type IDENTIFIER DOT attribute_name LPAREN RPAREN CIRCULAR? (expression_in_brackets)? (WITH IDENTIFIER)? (ROOT IDENTIFIER)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectCollAttributeImpl"
}
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 collection_contribution ::= annotation* IDENTIFIER 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_add_interface ::= IO IMPLEMENTS type_name_list SEMICOLON
...@@ -192,7 +213,7 @@ assignment_operator ::= ASSIGN | STARASSIGN | SLASHASSIGN | REMASSIGN | PLUSASSI ...@@ -192,7 +213,7 @@ assignment_operator ::= ASSIGN | STARASSIGN | SLASHASSIGN | REMASSIGN | PLUSASSI
conditional_expression ::= conditional_or_expression ( QUESTIONMARK expression COLON conditional_expression)? conditional_expression ::= conditional_or_expression ( QUESTIONMARK expression COLON conditional_expression)?
conditional_or_expression ::= conditional_and_expression ( SC_OR 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 )* conditional_and_expression ::= inclusive_or_expression ( SC_AND inclusive_or_expression )*
...@@ -238,7 +259,7 @@ boolean_literal ::= TRUE | FALSE ...@@ -238,7 +259,7 @@ boolean_literal ::= TRUE | FALSE
null_literal ::= NULL null_literal ::= NULL
arguments ::= LPAREN argument_list RPAREN arguments ::= LPAREN argument_list? RPAREN
argument_list ::= expression (COMMA expression)* argument_list ::= expression (COMMA expression)*
......
...@@ -28,6 +28,7 @@ MultiLineComment = "/*" [^*]+ [*]+([^*/][^*]*[*]+)*[/] ...@@ -28,6 +28,7 @@ MultiLineComment = "/*" [^*]+ [*]+([^*/][^*]*[*]+)*[/]
NotBrace = ( [^{}/]+ | [/][^{}/*] )+ NotBrace = ( [^{}/]+ | [/][^{}/*] )+
NotBracket = ( [^\[\]/]+ | [/][^\[\]/*] )+
// from jjt // from jjt
DecimalLiteral = [1-9] [0-9]* DecimalLiteral = [1-9] [0-9]*
...@@ -50,6 +51,7 @@ Identifier = [:jletter:] [:jletterdigit:]* ...@@ -50,6 +51,7 @@ Identifier = [:jletter:] [:jletterdigit:]*
%state EXPECT_CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE %state EXPECT_CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE
%state CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE %state CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE
%state LBRACE_ANYTHING_RBRACE %state LBRACE_ANYTHING_RBRACE
%state LBRACKET_ANYTHING_RBRACKET
%state JAVA_IN_PAREN %state JAVA_IN_PAREN
%state COLLECTION_DECL %state COLLECTION_DECL
%state ATTRIBUTE_DEFINITION %state ATTRIBUTE_DEFINITION
...@@ -94,6 +96,17 @@ Identifier = [:jletter:] [:jletterdigit:]* ...@@ -94,6 +96,17 @@ Identifier = [:jletter:] [:jletterdigit:]*
{NotBrace} {} {NotBrace} {}
} }
<LBRACKET_ANYTHING_RBRACKET> {
{SingleLineComment} {}
{FormalComment} {}
{MultiLineComment} {}
{CharacterLiteral} {}
{StringLiteral} {}
"[" { counter++; System.out.println("<INC>"); }
"]" { System.out.println("<DEC>"); counter--; if (counter==0) { System.out.println("<EXIT>"); yybegin(COLLECTION_DECL); return AspectTypes.LBRACKET_ANYTHING_RBRACKET; } }
{NotBracket} {System.out.println("<NB>" + yytext());}
}
<YYINITIAL,COLLECTION_DECL,ATTRIBUTE_DEFINITION> { <YYINITIAL,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
"abstract" { return AspectTypes.ABSTRACT; } "abstract" { return AspectTypes.ABSTRACT; }
//"assert" { return AspectTypes.ASSERT; } //"assert" { return AspectTypes.ASSERT; }
...@@ -126,7 +139,7 @@ Identifier = [:jletter:] [:jletterdigit:]* ...@@ -126,7 +139,7 @@ Identifier = [:jletter:] [:jletterdigit:]*
"interface" { return AspectTypes.INTERFACE; } "interface" { return AspectTypes.INTERFACE; }
"long" { return AspectTypes.LONG; } "long" { return AspectTypes.LONG; }
"native" { return AspectTypes.NATIVE; } "native" { return AspectTypes.NATIVE; }
//"new" { return AspectTypes.NEW; } "new" { return AspectTypes.NEW; }
"null" { return AspectTypes.NULL; } "null" { return AspectTypes.NULL; }
//"package" { return AspectTypes.PACKAGE; } //"package" { return AspectTypes.PACKAGE; }
"private" { return AspectTypes.PRIVATE; } "private" { return AspectTypes.PRIVATE; }
...@@ -139,7 +152,7 @@ Identifier = [:jletter:] [:jletterdigit:]* ...@@ -139,7 +152,7 @@ Identifier = [:jletter:] [:jletterdigit:]*
"super" { return AspectTypes.SUPER; } "super" { return AspectTypes.SUPER; }
//"switch" { return AspectTypes.SWITCH; } //"switch" { return AspectTypes.SWITCH; }
"synchronized" { return AspectTypes.SYNCHRONIZED; } "synchronized" { return AspectTypes.SYNCHRONIZED; }
//"this" { return AspectTypes.THIS; } "this" { return AspectTypes.THIS; }
//"throw" { return AspectTypes.THROW; } //"throw" { return AspectTypes.THROW; }
"throws" { return AspectTypes.THROWS; } "throws" { return AspectTypes.THROWS; }
"transient" { return AspectTypes.TRANSIENT; } "transient" { return AspectTypes.TRANSIENT; }
...@@ -174,6 +187,7 @@ Identifier = [:jletter:] [:jletterdigit:]* ...@@ -174,6 +187,7 @@ Identifier = [:jletter:] [:jletterdigit:]*
<COLLECTION_DECL> { <COLLECTION_DECL> {
"with" { return AspectTypes.WITH; } "with" { return AspectTypes.WITH; }
"root" { return AspectTypes.ROOT; } "root" { return AspectTypes.ROOT; }
"[" { yybegin(LBRACKET_ANYTHING_RBRACKET); System.out.println("<ENTER>"); counter = 1; }
} }
<ATTRIBUTE_DEFINITION> { <ATTRIBUTE_DEFINITION> {
......
package org.jastadd.tooling.aspect.psi;
import com.intellij.psi.PsiElement;
public interface JastAddAspectAttribute extends PsiElement {
}
package org.jastadd.tooling.aspect.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import org.jastadd.tooling.aspect.psi.JastAddAspectAttribute;
import org.jetbrains.annotations.NotNull;
public abstract class JastAddAspectCollAttributeImpl extends ASTWrapperPsiElement implements JastAddAspectAttribute {
public JastAddAspectCollAttributeImpl(@NotNull ASTNode node) {
super(node);
}
}
package org.jastadd.tooling.aspect.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import org.jastadd.tooling.aspect.psi.JastAddAspectAttribute;
import org.jetbrains.annotations.NotNull;
public abstract class JastAddAspectInhAttributeImpl extends ASTWrapperPsiElement implements JastAddAspectAttribute {
public JastAddAspectInhAttributeImpl(@NotNull ASTNode node) {
super(node);
}
}
package org.jastadd.tooling.aspect.psi.impl;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import org.jastadd.tooling.aspect.psi.JastAddAspectAttribute;
import org.jetbrains.annotations.NotNull;
public abstract class JastAddAspectSynAttributeImpl extends ASTWrapperPsiElement implements JastAddAspectAttribute {
public JastAddAspectSynAttributeImpl(@NotNull ASTNode node) {
super(node);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment