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

move from island to full parsing

parent 62cbe6c6
No related branches found
No related tags found
No related merge requests found
Pipeline #11828 passed
......@@ -50,7 +50,7 @@ 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 ) )
type_declaration ::= SEMICOLON | (modifiers ( class_declaration | interface_declaration | unmodified_enum_declaration | annotation_type_declaration | aspect_declaration ) )
aspect_declaration ::= ASPECT IDENTIFIER aspect_body
......@@ -77,12 +77,17 @@ aspect_body_declaration ::= ( aspect_refine_inh_equation
| 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 IDENTIFIER type_parameters? (EXTENDS type_name_list)? LBRACE aspect_interface_member_declaration* RBRACE
aspect_interface_member_declaration ::= ( aspect_nested_class_declaration
......@@ -92,13 +97,13 @@ aspect_interface_member_declaration ::= ( aspect_nested_class_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_syn_attribute_declaration ::= annotation* SYN LAZY? FINAL? aspect_type attribute_name LPAREN (type IDENTIFIER (COMMA type IDENTIFIER)* )? RPAREN (CIRCULAR LBRACKET expression RBRACKET)? 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 LBRACKET expression RBRACKET)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectInhAttributeImpl"
......@@ -108,8 +113,10 @@ aspect_interface_method_declaration ::= (PUBLIC | PROTECTED | PRIVATE | STATIC |
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 IDENTIFIER DOT method_declarator (THROWS name_list)? (block | SEMICOLON)
......@@ -122,13 +129,13 @@ aspect_refine_constructor_declaration ::= REFINE IDENTIFIER (PUBLIC | PROTECTED
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 LBRACKET expression RBRACKET)? ( 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)* )? RPAREN (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 LBRACKET expression RBRACKET)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectInhAttributeImpl"
......@@ -145,7 +152,7 @@ aspect_inh_equation ::= annotation* EQUATION IDENTIFIER DOT IDENTIFIER LPAREN (I
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? (LBRACKET expression RBRACKET)? (WITH IDENTIFIER)? (ROOT IDENTIFIER)? SEMICOLON
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectAttribute"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectCollAttributeImpl"
......@@ -153,40 +160,70 @@ collection_attribute ::= annotation* COLL aspect_type IDENTIFIER DOT attribute_n
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 ::= IDENTIFIER IMPLEMENTS type_name_list SEMICOLON
aspect_extend_interface ::= IDENTIFIER EXTENDS type_name_list SEMICOLON
// added
class_declaration ::= CLASS IDENTIFIER 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)*
attribute_name ::= IDENTIFIER
unmodified_class_declaration ::= CLASS IDENTIFIER type_parameters? (EXTENDS class_or_interface_type)? (IMPLEMENTS type_name_list)? class_body
// TODO | UnmodifiedClassDeclaration("")
block_statement ::= (FINAL? type java_identifier local_variable_declaration SEMICOLON) | statement
// TODO check simplification
aspect_enum_declaration ::= modifiers ENUM IDENTIFIER (IMPLEMENTS type_name_list)? enum_body
aspect_cache_declaration ::= (CACHE | UNCACHE) IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER? (type IDENTIFIER?)* )? RPAREN SEMICOLON
unmodified_enum_declaration ::= ENUM java_identifier (IMPLEMENTS type_name_list)? enum_body
java_identifier ::= IDENTIFIER | INH | SYN | LAZY | REWRITE | TO | WHEN | ASPECT | EQUATION | CIRCULAR | REFINE | COLL | CONTRIBUTES | EACH | NTA | CACHE | UNCACHE
enum_body ::= LBRACE enum_constant (COMMA enum_constant)* (SEMICOLON class_body_declaration*)? RBRACE
// Attribute type names can not start with JastAdd reserved words such as 'syn', 'eq', etc.
aspect_type ::= aspect_reference_type | ( primitive_type (LBRACKET RBRACKET)? )
enum_constant ::= java_identifier arguments? class_body?
formal_parameters ::= LPAREN ( formal_parameter ( COMMA formal_parameter )* )? RPAREN
type_parameters ::= LT type_parameter (COMMA type_parameter)* GT
formal_parameter ::= FINAL? type DOTS? variable_declarator_id
type_parameter ::= java_identifier type_bound?
variable_declarator_id ::= java_identifier ( LBRACKET RBRACKET )*
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
aspect_enum_declaration ::= modifiers enum_declaration
unmodified_interface_declaration ::= INTERFACE IDENTIFIER 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 ::= IDENTIFIER type_arguments? (DOT java_identifier type_arguments? )*
......@@ -257,7 +294,9 @@ 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
// member_selector unused!
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
......@@ -283,64 +322,99 @@ 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)*
type_parameters ::= LT type_parameter (COMMA type_parameter)* GT
empty_statement ::= SEMICOLON
type_parameter ::= java_identifier type_bound?
statement_expression ::= pre_increment_expression | pre_decrement_expression | ( primary_expression ( INCR | DECR | assignment_operator expression )? )
type_bound ::= EXTENDS class_or_interface_type (AMPERSAND class_or_interface_type)*
switch_statement ::= SWITCH LPAREN expression RPAREN LBRACE ( switch_label block_statement* )* RBRACE
aspect_result_type ::= VOID | aspect_type
switch_label ::= CASE expression COLON | DEFAULT COLON
method_declarator ::= java_identifier formal_parameters (LBRACKET RBRACKET)*
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 LPAREN member_value_pairs? RPAREN
marker_annotation ::= AT name
single_member_annotation ::= AT name LPAREN member_value RPAREN
member_value_pairs ::= member_value_pair (COMMA member_value_pair)*
member_value_pair ::= java_identifier ASSIGN member_value
// island things
member_value ::= annotation | member_value_array_initializer | conditional_expression
//class_body_declaration_in_paren ::= JAVA_IN_PAREN
//{
// implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
// extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
//}
member_value_array_initializer ::= LBRACE member_value ( COMMA member_value )* COMMA? RBRACE
// should be parsed after circular and in collection attributes
expression_in_brackets ::= LBRACKET_ANYTHING_RBRACKET // LBRACKET expression RBRACKET
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
}
annotation_type_declaration ::= AT INTERFACE java_identifier annotation_type_body
// 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
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
// 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
default_value ::= DEFAULT member_value
// 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
aspect_cache_declaration ::= (CACHE | UNCACHE) IDENTIFIER DOT attribute_name LPAREN (type IDENTIFIER? (type IDENTIFIER?)* )? RPAREN SEMICOLON
// 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
java_identifier ::= IDENTIFIER | INH | SYN | LAZY | REWRITE | TO | WHEN | ASPECT | EQUATION | CIRCULAR | REFINE | COLL | CONTRIBUTES | EACH | NTA | CACHE | UNCACHE
// only within attribute equations
block ::= LBRACE_ANYTHING_RBRACE
{
implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
}
attribute_name ::= IDENTIFIER
// TODO unsupported
// EOF
class_body ::= CLASS_BODY_UNSUPPORTED
// unused keywords
unused_keywords ::= GOTO | CONST ELLIPSIS | PACKAGE
// island things
//// should be parsed after circular and in collection attributes
//expression_in_brackets ::= LBRACKET_ANYTHING_RBRACKET // LBRACKET expression RBRACKET
//{
// implements="org.jastadd.tooling.aspect.psi.JastAddAspectJavaExtension"
// extends="org.jastadd.tooling.aspect.psi.impl.JastAddAspectJavaImplExtension"
//}
......@@ -17,6 +17,19 @@ import com.intellij.psi.TokenType;
%{
private int counter = 0;
private int totalBraceLevel = 0;
private java.util.Stack<Integer> modeStack = new java.util.Stack<>();
private void enterState(int state) {
System.out.println("in state" + yystate() + ", entering state " + state);
modeStack.push(yystate());
yybegin(state);
}
private void exitState() {
System.out.println("in state" + yystate() + ", exiting to state " + modeStack.peek());
yybegin(modeStack.pop());
}
%}
WhiteSpace = [ \t\n\r\f]
......@@ -47,91 +60,44 @@ StringLiteral = \" ( [^\"\\\n\r] | ( \\ ( [ntbrf\\'\"] | [0-7][0-7?] | [0
Identifier = [:jletter:] [:jletterdigit:]*
%state JASTADD
%state EXPECT_CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE
%state CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE
%state LBRACE_ANYTHING_RBRACE
%state LBRACKET_ANYTHING_RBRACKET
%state JAVA_IN_PAREN
%state IN_ASPECT
%state COLLECTION_DECL
%state ATTRIBUTE_DEFINITION
%state LPAREN_ANYTHING_RPAREN
%%
<YYINITIAL,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
<YYINITIAL,IN_ASPECT,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
{WhiteSpace}+ { return TokenType.WHITE_SPACE; }
{SingleLineComment} { return AspectTypes.SINGLE_LINE_COMMENT; }
{FormalComment} { return AspectTypes.FORMAL_COMMENT; }
{MultiLineComment} { return AspectTypes.MULTI_LINE_COMMENT; }
// "EQ" { yybegin(YYINITIAL); return AspectTypes.EQ; }
// "{" { yybegin(JAVA); counter = 1; }
"class" { yybegin(EXPECT_CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE); }
}
<EXPECT_CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE> {
"{" { yybegin(CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE); counter = 1; }
{NotBrace} {} // skip over everything
}
<CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE> {
{SingleLineComment} {}
{FormalComment} {}
{MultiLineComment} {}
{CharacterLiteral} {}
{StringLiteral} {}
"{" { counter++; }
"}" { counter--; if (counter==0) { yybegin(YYINITIAL); return AspectTypes.CLASS_ANYTHING_LBRACE_ANYTHING_RBRACE; } }
{NotBrace} {}
}
<LBRACE_ANYTHING_RBRACE> {
{SingleLineComment} {}
{FormalComment} {}
{MultiLineComment} {}
{CharacterLiteral} {}
{StringLiteral} {}
"{" { counter++; }
"}" { counter--; if (counter==0) { yybegin(YYINITIAL); return AspectTypes.LBRACE_ANYTHING_RBRACE; } }
{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,IN_ASPECT,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
"abstract" { return AspectTypes.ABSTRACT; }
//"assert" { return AspectTypes.ASSERT; }
"assert" { return AspectTypes.ASSERT; }
"boolean" { return AspectTypes.BOOLEAN; }
//"break" { return AspectTypes.BREAK; }
"break" { return AspectTypes.BREAK; }
"byte" { return AspectTypes.BYTE; }
//"case" { return AspectTypes.CASE; }
//"catch" { return AspectTypes.CATCH; }
"case" { return AspectTypes.CASE; }
"catch" { return AspectTypes.CATCH; }
"char" { return AspectTypes.CHAR; }
//"class" { return AspectTypes.CLASS; }
//"const" { return AspectTypes.CONST; }
//"continue" { return AspectTypes.CONTINUE; }
//"default" { return AspectTypes._DEFAULT; }
//"do" { return AspectTypes.DO; }
"class" { return AspectTypes.CLASS; }
"const" { return AspectTypes.CONST; }
"continue" { return AspectTypes.CONTINUE; }
"default" { return AspectTypes.DEFAULT; }
"do" { return AspectTypes.DO; }
"double" { return AspectTypes.DOUBLE; }
//"else" { return AspectTypes.ELSE; }
//"enum" { return AspectTypes.ENUM; }
"else" { return AspectTypes.ELSE; }
"enum" { return AspectTypes.ENUM; }
"extends" { return AspectTypes.EXTENDS; }
"false" { return AspectTypes.FALSE; }
"final" { return AspectTypes.FINAL; }
//"finally" { return AspectTypes.FINALLY; }
"finally" { return AspectTypes.FINALLY; }
"float" { return AspectTypes.FLOAT; }
"for" { return AspectTypes.FOR; }
//"goto" { return AspectTypes.GOTO; }
//"if" { return AspectTypes.IF; }
"goto" { return AspectTypes.GOTO; }
"if" { return AspectTypes.IF; }
"implements" { return AspectTypes.IMPLEMENTS; }
"import" { return AspectTypes.IMPORT; }
"instanceof" { return AspectTypes.INSTANCEOF; }
......@@ -141,36 +107,39 @@ Identifier = [:jletter:] [:jletterdigit:]*
"native" { return AspectTypes.NATIVE; }
"new" { return AspectTypes.NEW; }
"null" { return AspectTypes.NULL; }
//"package" { return AspectTypes.PACKAGE; }
"package" { return AspectTypes.PACKAGE; }
"private" { return AspectTypes.PRIVATE; }
"protected" { return AspectTypes.PROTECTED; }
"public" { return AspectTypes.PUBLIC; }
//"return" { return AspectTypes.RETURN; }
"return" { return AspectTypes.RETURN; }
"short" { return AspectTypes.SHORT; }
"static" { return AspectTypes.STATIC; }
"strictfp" { return AspectTypes.STRICTFP; }
"super" { return AspectTypes.SUPER; }
//"switch" { return AspectTypes.SWITCH; }
"switch" { return AspectTypes.SWITCH; }
"synchronized" { return AspectTypes.SYNCHRONIZED; }
"this" { return AspectTypes.THIS; }
//"throw" { return AspectTypes.THROW; }
"throw" { return AspectTypes.THROW; }
"throws" { return AspectTypes.THROWS; }
"transient" { return AspectTypes.TRANSIENT; }
"true" { return AspectTypes.TRUE; }
//"try" { return AspectTypes.TRY; }
"try" { return AspectTypes.TRY; }
"void" { return AspectTypes.VOID; }
"volatile" { return AspectTypes.VOLATILE; }
//"while" { return AspectTypes.WHILE; }
"while" { return AspectTypes.WHILE; }
// JastAdd
"inh" { yybegin(ATTRIBUTE_DEFINITION); return AspectTypes.INH; }
"syn" { yybegin(ATTRIBUTE_DEFINITION); return AspectTypes.SYN; }
// the only jastadd-specific keyword here is aspect
"aspect" { enterState(IN_ASPECT); return AspectTypes.ASPECT; }
}
<IN_ASPECT,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
"inh" { enterState(ATTRIBUTE_DEFINITION); return AspectTypes.INH; }
"syn" { enterState(ATTRIBUTE_DEFINITION); return AspectTypes.SYN; }
"lazy" { return AspectTypes.LAZY; }
"rewrite" { return AspectTypes.REWRITE; }
"to" { return AspectTypes.TO; }
"when" { return AspectTypes.WHEN; }
"aspect" { return AspectTypes.ASPECT; }
"eq" { yybegin(ATTRIBUTE_DEFINITION); return AspectTypes.EQUATION; }
"eq" { enterState(ATTRIBUTE_DEFINITION); return AspectTypes.EQUATION; }
"circular" { return AspectTypes.CIRCULAR; }
"refine" { return AspectTypes.REFINE; }
"contributes" { return AspectTypes.CONTRIBUTES; }
......@@ -180,26 +149,26 @@ Identifier = [:jletter:] [:jletterdigit:]*
"uncache" { return AspectTypes.UNCACHE; }
// TODO this is strangely split in another Token block, check semantics of JJTree file!
"coll" { yybegin(COLLECTION_DECL); return AspectTypes.COLL; }
"coll" { enterState(COLLECTION_DECL); return AspectTypes.COLL; }
}
<COLLECTION_DECL> {
"with" { return AspectTypes.WITH; }
"root" { return AspectTypes.ROOT; }
"[" { yybegin(LBRACKET_ANYTHING_RBRACKET); System.out.println("<ENTER>"); counter = 1; }
"[" { return AspectTypes.LBRACKET; }
}
<ATTRIBUTE_DEFINITION> {
"{" { yybegin(LBRACE_ANYTHING_RBRACE); counter = 1; }
"{" { ++totalBraceLevel; return AspectTypes.LBRACE; }
}
// a semicolon exits the COLLECTION_DECL (because we ignore semicolons in expressions)
<COLLECTION_DECL, ATTRIBUTE_DEFINITION> {
";" { yybegin(YYINITIAL); return AspectTypes.SEMICOLON; }
";" { exitState(); return AspectTypes.SEMICOLON; }
}
<YYINITIAL,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
<YYINITIAL,IN_ASPECT,COLLECTION_DECL,ATTRIBUTE_DEFINITION> {
// LITERALS
{IntegerLiteral} { return AspectTypes.INTEGER_LITERAL; }
{FloatingPointLiteral} { return AspectTypes.FLOATING_POINT_LITERAL; }
......@@ -209,22 +178,19 @@ Identifier = [:jletter:] [:jletterdigit:]*
// IDENTIFIERS
{Identifier} { return AspectTypes.IDENTIFIER; }
// COMBINED TOKENS
".class" { return AspectTypes.DOT_CLASS; }
// SEPARATORS
"(" { return AspectTypes.LPAREN; }
")" { return AspectTypes.RPAREN; }
"{" { return AspectTypes.LBRACE; }
"}" { return AspectTypes.RBRACE; }
"{" { ++totalBraceLevel; return AspectTypes.LBRACE; }
"}" { --totalBraceLevel; if (totalBraceLevel == 0) { exitState(); } return AspectTypes.RBRACE; }
"[" { return AspectTypes.LBRACKET; }
"]" { return AspectTypes.RBRACKET; }
";" { return AspectTypes.SEMICOLON; }
"," { return AspectTypes.COMMA; }
"." { return AspectTypes.DOT; }
//"@" { return AspectTypes.AT; }
"@" { return AspectTypes.AT; }
// OPERATORS
"=" { return AspectTypes.ASSIGN; }
......@@ -261,7 +227,7 @@ Identifier = [:jletter:] [:jletterdigit:]*
"<<=" { return AspectTypes.LSHIFTASSIGN; }
">>=" { return AspectTypes.RSIGNEDSHIFTASSIGN; }
">>>=" { return AspectTypes.RUNSIGNEDSHIFTASSIGN; }
//"..." { return AspectTypes.ELLIPSIS; }
"..." { return AspectTypes.ELLIPSIS; }
"->" { return AspectTypes.ARROW; }
"::" { return AspectTypes.DOUBLECOLON; }
......
......@@ -22,22 +22,11 @@ public class JavaLanguageInjector implements LanguageInjector {
@Override
public void getLanguagesToInject(@NotNull PsiLanguageInjectionHost host, @NotNull InjectedLanguagePlaces injectionPlacesRegistrar) {
if (host.isValidHost()) {
if (host instanceof JastAddAspectNormalAnnotation) {
// TODO
} else if (host instanceof JastAddAspectSingleMemberAnnotation) {
// TODO
} else if (host instanceof JastAddAspectInterfaceDeclaration) {
// TODO
} else if (host instanceof JastAddAspectEnumDeclaration) {
// TODO
} else if (host instanceof JastAddAspectAnnotationTypeDeclaration) {
// TODO
} else if (host instanceof JastAddAspectBlock) {
// TODO more injections
if (host instanceof JastAddAspectBlock) {
injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(1, host.getTextLength() - 1), "class X { public void m() {", "}}");
} else if (host instanceof JastAddAspectExpression) {
injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(0, host.getTextLength()), "class X { public void m() {Object x = ", ";}}");
} else if (host instanceof JastAddAspectExpressionInBrackets) {
injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(1, host.getTextLength() - 1), "class X { public void m() {Object x = ", ";}}");
} else if (host instanceof JastAddAspectAspectClassDeclaration) {
injectionPlacesRegistrar.addPlace(JavaLanguage.INSTANCE, new TextRange(0, host.getTextLength()), "", "");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment