mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
change class_base to be a list of ^(IMPLEMENTS type). Easier to convert first to EXTENDS if its a class
This commit is contained in:
parent
0cbed4a779
commit
163b651cd6
@ -869,10 +869,10 @@ type_parameter returns [string name]:
|
|||||||
|
|
||||||
class_base:
|
class_base:
|
||||||
// just put all types in a single list. In NetMaker we will extract the base class if necessary
|
// just put all types in a single list. In NetMaker we will extract the base class if necessary
|
||||||
':' interface_type_list -> ^(IMPLEMENTS interface_type_list);
|
':' ts+=type (',' ts+=type)* -> ^(IMPLEMENTS $ts)*;
|
||||||
|
|
||||||
interface_type_list:
|
//interface_type_list:
|
||||||
ts+=type (',' ts+=type)* -> $ts+;
|
// ts+=type (',' ts+=type)* -> $ts+;
|
||||||
|
|
||||||
class_body:
|
class_body:
|
||||||
'{' class_member_declarations? '}' ;
|
'{' class_member_declarations? '}' ;
|
||||||
@ -1163,7 +1163,7 @@ scope TypeContext;
|
|||||||
-> ^(INTERFACE[$c.Token] identifier type_parameter_constraints_clauses? variant_generic_parameter_list? interface_base? interface_body );
|
-> ^(INTERFACE[$c.Token] identifier type_parameter_constraints_clauses? variant_generic_parameter_list? interface_base? interface_body );
|
||||||
|
|
||||||
interface_base:
|
interface_base:
|
||||||
':' interface_type_list -> ^(EXTENDS interface_type_list);
|
':' ts+=type (',' ts+=type)* -> ^(IMPLEMENTS $ts)*;
|
||||||
|
|
||||||
interface_modifiers:
|
interface_modifiers:
|
||||||
modifier+ ;
|
modifier+ ;
|
||||||
|
@ -221,8 +221,9 @@ compilation_unit
|
|||||||
initPrecedence();
|
initPrecedence();
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
^(PACKAGE nm=PAYLOAD modifiers? type_declaration[$modifiers.st] { if (IsLast) collectComments(); }) ->
|
^(PACKAGE nm=PAYLOAD imports? modifiers? type_declaration[$modifiers.st] { if (IsLast) collectComments(); }) ->
|
||||||
package(now = {DateTime.Now}, includeDate = {Cfg.TranslatorAddTimeStamp}, packageName = {($nm.text != null && $nm.text.Length > 0 ? $nm.text : null)},
|
package(now = {DateTime.Now}, includeDate = {Cfg.TranslatorAddTimeStamp}, packageName = {($nm.text != null && $nm.text.Length > 0 ? $nm.text : null)},
|
||||||
|
imports = {$imports.st},
|
||||||
type = {$type_declaration.st},
|
type = {$type_declaration.st},
|
||||||
endComments = { CollectedComments });
|
endComments = { CollectedComments });
|
||||||
|
|
||||||
@ -247,6 +248,11 @@ modifier
|
|||||||
(m='new' | m='public' | m='protected' | m='private' | m='abstract' | m='sealed' | m='static'
|
(m='new' | m='public' | m='protected' | m='private' | m='abstract' | m='sealed' | m='static'
|
||||||
| m='readonly' | m='volatile' | m='extern' { thetext = "/* [UNSUPPORTED] 'extern' modifier not supported */"; } | m='virtual' | m='override' | m=FINAL)
|
| m='readonly' | m='volatile' | m='extern' { thetext = "/* [UNSUPPORTED] 'extern' modifier not supported */"; } | m='virtual' | m='override' | m=FINAL)
|
||||||
-> string(payload={ (thetext == null ? $m.text : thetext) });
|
-> string(payload={ (thetext == null ? $m.text : thetext) });
|
||||||
|
|
||||||
|
imports:
|
||||||
|
imps+=importns+ -> seplist(items = { $imps }, sep= { "\n" });
|
||||||
|
importns:
|
||||||
|
IMPORT PAYLOAD -> import_template(ns = { $PAYLOAD.text });
|
||||||
|
|
||||||
class_member_declaration returns [List<String> preComments]:
|
class_member_declaration returns [List<String> preComments]:
|
||||||
^(CONST attributes? modifiers? type { $preComments = CollectedComments; } constant_declarators)
|
^(CONST attributes? modifiers? type { $preComments = CollectedComments; } constant_declarators)
|
||||||
@ -831,9 +837,11 @@ type_parameter [Dictionary<string,StringTemplate> tpConstraints]
|
|||||||
identifier {if (tpConstraints == null || !tpConstraints.TryGetValue($identifier.text, out mySt)) {mySt = $identifier.st;}; } -> { mySt } ;
|
identifier {if (tpConstraints == null || !tpConstraints.TryGetValue($identifier.text, out mySt)) {mySt = $identifier.st;}; } -> { mySt } ;
|
||||||
|
|
||||||
class_extends:
|
class_extends:
|
||||||
^(EXTENDS ts+=type*) -> extends(types = { $ts }) ;
|
^(EXTENDS ts=type) -> extends(types = { $ts.st }) ;
|
||||||
class_implements:
|
class_implements:
|
||||||
^(IMPLEMENTS ts+=type*) -> imps(types = { $ts }) ;
|
ts+=class_implement+ -> imps(types = { $ts }) ;
|
||||||
|
class_implement:
|
||||||
|
^(IMPLEMENTS ts=type) -> seplist(items = { $ts.st }, sep={", "}) ;
|
||||||
|
|
||||||
interface_type_list:
|
interface_type_list:
|
||||||
ts+=type (',' ts+=type)* -> commalist(items={ $ts });
|
ts+=type (',' ts+=type)* -> commalist(items={ $ts });
|
||||||
|
@ -535,10 +535,18 @@ type_parameter_list:
|
|||||||
type_parameter:
|
type_parameter:
|
||||||
identifier ;
|
identifier ;
|
||||||
|
|
||||||
class_extends:
|
//class_extends:
|
||||||
^(EXTENDS type*) ;
|
// ^(EXTENDS type*) ;
|
||||||
|
|
||||||
|
// If first implements type is a class then convert to extends
|
||||||
class_implements:
|
class_implements:
|
||||||
^(IMPLEMENTS type*) ;
|
class_implement_or_extend class_implement* ;
|
||||||
|
|
||||||
|
class_implement_or_extend:
|
||||||
|
^(i=IMPLEMENTS type) -> ^(EXTENDS[$i.token, "extends"] type);
|
||||||
|
|
||||||
|
class_implement:
|
||||||
|
^(IMPLEMENTS type) ;
|
||||||
|
|
||||||
interface_type_list:
|
interface_type_list:
|
||||||
type (',' type)* ;
|
type (',' type)* ;
|
||||||
@ -678,7 +686,7 @@ parameter_array:
|
|||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
interface_declaration:
|
interface_declaration:
|
||||||
^(INTERFACE identifier type_parameter_constraints_clauses? variant_generic_parameter_list?
|
^(INTERFACE identifier type_parameter_constraints_clauses? variant_generic_parameter_list?
|
||||||
class_extends? interface_body ) ;
|
class_implements? interface_body ) ;
|
||||||
interface_modifiers:
|
interface_modifiers:
|
||||||
modifier+ ;
|
modifier+ ;
|
||||||
interface_base:
|
interface_base:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user