mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Convert properties to methods
This commit is contained in:
parent
4e6828f24f
commit
8a9eea3fcc
@ -198,9 +198,9 @@ class_member_declaration:
|
||||
| i2=interface_declaration -> ^(INTERFACE[$i2.start.Token, "INTERFACE"] $a? $m? $i2) // 'interface'
|
||||
| v2=void_type m1=method_declaration[$a.tree, $m.tree, $v2.tree] -> $m1 //-> ^(METHOD[$v.token, "METHOD"] $a? $m? ^(TYPE[$v.token, "TYPE"] $v) $m1)
|
||||
| t=type ( (member_name type_parameter_list? '(') => m2=method_declaration[$a.tree, $m.tree, $t.tree] -> $m2
|
||||
| (member_name '{') => property_declaration -> ^(PROPERTY[$t.start.Token, "PROPERTY"] $a? $m? $t property_declaration)
|
||||
| (member_name '.' 'this') => type_name '.' ix1=indexer_declaration -> ^(INDEXER[$t.start.Token, "INDEXER"] $a? $m? $t type_name $ix1)
|
||||
| ix2=indexer_declaration -> ^(INDEXER[$t.start.Token,"INDEXER"] $a? $m? $t $ix2) //this
|
||||
| (member_name '{') => pd=property_declaration[$a.tree, $m.tree, $t.tree] -> $pd
|
||||
| (member_name '.' 'this') => type_name '.' ix1=indexer_declaration[$a.tree, $m.tree, $t.tree] -> $ix1
|
||||
| ix2=indexer_declaration[$a.tree, $m.tree, $t.tree] -> $ix2 //this
|
||||
| field_declaration -> ^(FIELD[$t.start.Token, "FIELD"] $a? $m? $t field_declaration) // qid
|
||||
| operator_declaration -> ^(OPERATOR[$t.start.Token, "OPERATOR"] $a? $m? $t operator_declaration)
|
||||
)
|
||||
@ -731,7 +731,7 @@ constant_expression:
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
field_declaration:
|
||||
variable_declarators ';' ;
|
||||
variable_declarators ';'! ;
|
||||
variable_declarators:
|
||||
variable_declarator (',' variable_declarator)* ;
|
||||
variable_declarator:
|
||||
@ -746,8 +746,8 @@ method_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
||||
|
||||
method_body:
|
||||
block ;
|
||||
member_name :
|
||||
(type_or_generic '.')* identifier
|
||||
member_name returns [String rawId]:
|
||||
(type_or_generic '.')* i=identifier { $rawId = $i.text; }
|
||||
// keving [interface_type.identifier] | type_name '.' identifier
|
||||
;
|
||||
|
||||
@ -755,20 +755,32 @@ member_name_orig returns [string name, List<String> tyargs]:
|
||||
qid { $name = $qid.name; $tyargs = $qid.tyargs; } ; // IInterface<int>.Method logic added.
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
property_declaration:
|
||||
member_name '{' accessor_declarations '}' ;
|
||||
accessor_declarations:
|
||||
attributes?
|
||||
(get_accessor_declaration attributes? set_accessor_declaration?
|
||||
| set_accessor_declaration attributes? get_accessor_declaration?) ;
|
||||
get_accessor_declaration:
|
||||
accessor_modifier? 'get' accessor_body ;
|
||||
set_accessor_declaration:
|
||||
accessor_modifier? 'set' accessor_body ;
|
||||
property_declaration [CommonTree atts, CommonTree mods, CommonTree type]
|
||||
scope { bool emptyGetterSetter; }
|
||||
@init {
|
||||
$property_declaration::emptyGetterSetter = false;
|
||||
CommonTree privateVar = null;
|
||||
}
|
||||
:
|
||||
i=member_name '{' ads=accessor_declarations[atts, mods, type, $i.text, $i.rawId] '}'
|
||||
v=magicMkPropertyVar[type, "__" + $i.tree.Text] { privateVar = $property_declaration::emptyGetterSetter ? $v.tree : null; }-> { privateVar } $ads ;
|
||||
|
||||
accessor_declarations [CommonTree atts, CommonTree mods, CommonTree type, String propName, String rawVarName]:
|
||||
accessor_declaration[atts, mods, type, propName, rawVarName]+;
|
||||
|
||||
accessor_declaration [CommonTree atts, CommonTree mods, CommonTree type, String propName, String rawVarName]
|
||||
@init {
|
||||
CommonTree propBlock = null;
|
||||
bool mkBody = false;
|
||||
}:
|
||||
la=attributes? lm=accessor_modifier?
|
||||
(g='get' ((';')=> gbe=';' { $property_declaration::emptyGetterSetter = true; propBlock = $gbe.tree; mkBody = true; rawVarName = "__" + rawVarName; }
|
||||
| gb=block { propBlock = $gb.tree; } ) getm=magicPropGetter[atts, $la.tree, mods, $lm.tree, type, $g.token, propBlock, propName, mkBody, rawVarName] -> $getm
|
||||
| s='set' ((';')=> sbe=';' { $property_declaration::emptyGetterSetter = true; propBlock = $sbe.tree; mkBody = true; rawVarName = "__" + rawVarName; }
|
||||
| sb=block { propBlock = $sb.tree; } ) setm=magicPropSetter[atts, $la.tree, mods, $lm.tree, type, $s.token, propBlock, propName, mkBody, rawVarName] -> $setm)
|
||||
;
|
||||
accessor_modifier:
|
||||
'public' | 'protected' | 'private' | 'internal' ;
|
||||
accessor_body:
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
event_declaration:
|
||||
@ -927,12 +939,13 @@ interface_member_declaration:
|
||||
(vt=void_type im1=interface_method_declaration[$a.tree, $m.tree, $vt.tree] -> $im1
|
||||
| ie=interface_event_declaration[$a.tree, $m.tree] -> $ie
|
||||
| t=type ( (member_name '(') => im2=interface_method_declaration[$a.tree, $m.tree, $t.tree] -> $im2
|
||||
| (member_name '{') => ip=interface_property_declaration[$a.tree, $m.tree, $t.tree] -> ^(PROPERTY[$t.start.Token, "PROPERTY"] $a? $m? $t interface_property_declaration)
|
||||
// property will rewrite to one, or two method headers
|
||||
| (member_name '{') => ip=interface_property_declaration[$a.tree, $m.tree, $t.tree] -> $ip //^(PROPERTY[$t.start.Token, "PROPERTY"] $a? $m? $t interface_property_declaration)
|
||||
| ii=interface_indexer_declaration[$a.tree, $m.tree, $t.tree] -> $ii)
|
||||
)
|
||||
;
|
||||
interface_property_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
||||
identifier '{' interface_accessor_declarations '}' ;
|
||||
i=identifier '{' iads=interface_accessor_declarations[atts, mods, type, $i.text] '}' -> $iads ;
|
||||
interface_method_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
||||
identifier generic_argument_list?
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ';'
|
||||
@ -943,17 +956,14 @@ interface_event_declaration [CommonTree atts, CommonTree mods]:
|
||||
'event' type identifier ';' ;
|
||||
interface_indexer_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
||||
// attributes? 'new'? type
|
||||
'this' '[' formal_parameter_list ']' '{' interface_accessor_declarations '}' ;
|
||||
interface_accessor_declarations:
|
||||
attributes?
|
||||
(interface_get_accessor_declaration attributes? interface_set_accessor_declaration?
|
||||
| interface_set_accessor_declaration attributes? interface_get_accessor_declaration?) ;
|
||||
interface_get_accessor_declaration:
|
||||
'get' ';' ; // no body / modifiers
|
||||
interface_set_accessor_declaration:
|
||||
'set' ';' ; // no body / modifiers
|
||||
method_modifiers:
|
||||
modifier+ ;
|
||||
'this' '[' formal_parameter_list ']' '{' interface_accessor_declarations[atts,mods,type, "INDEX"] '}' ;
|
||||
interface_accessor_declarations [CommonTree atts, CommonTree mods, CommonTree type, String propName]:
|
||||
interface_accessor_declaration[atts, mods, type, propName]+
|
||||
;
|
||||
interface_accessor_declaration [CommonTree atts, CommonTree mods, CommonTree type, String propName]:
|
||||
la=attributes? (g='get' semi=';' magicPropGetter[atts, $la.tree, mods, null, type, $g.token, $semi.tree, propName, false, ""] -> magicPropGetter
|
||||
| s='set' semi=';' magicPropSetter[atts, $la.tree, mods, null, type, $s.token, $semi.tree, propName, false, ""] -> magicPropSetter)
|
||||
;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
struct_declaration returns [string name]:
|
||||
@ -961,49 +971,49 @@ struct_declaration returns [string name]:
|
||||
-> ^(CLASS[$c.Token] identifier type_parameter_constraints_clauses? type_parameter_list? class_base? class_body );
|
||||
|
||||
// UNUSED, HOPEFULLY
|
||||
struct_modifiers:
|
||||
struct_modifier+ ;
|
||||
struct_modifier:
|
||||
'new' | 'public' | 'protected' | 'internal' | 'private' | 'unsafe' ;
|
||||
struct_interfaces:
|
||||
':' interface_type_list;
|
||||
struct_body:
|
||||
'{' struct_member_declarations? '}';
|
||||
struct_member_declarations:
|
||||
struct_member_declaration+ ;
|
||||
struct_member_declaration:
|
||||
attributes? m=modifiers?
|
||||
( 'const' type constant_declarators ';'
|
||||
| event_declaration // 'event'
|
||||
| p='partial' { Warning($p.line, "[UNSUPPORTED] 'partial' definition"); } (v1=void_type method_declaration[$attributes.tree, $modifiers.tree, $v1.tree]
|
||||
| interface_declaration
|
||||
| class_declaration
|
||||
| struct_declaration)
|
||||
|
||||
| interface_declaration // 'interface'
|
||||
| class_declaration // 'class'
|
||||
| v2=void_type method_declaration[$attributes.tree, $modifiers.tree, $v2.tree]
|
||||
| t1=type ( (member_name type_parameter_list? '(') => method_declaration[$attributes.tree, $modifiers.tree, $t1.tree]
|
||||
| (member_name '{') => property_declaration
|
||||
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||
| indexer_declaration //this
|
||||
| field_declaration // qid
|
||||
| operator_declaration
|
||||
)
|
||||
// common_modifiers// (method_modifiers | field_modifiers)
|
||||
|
||||
| struct_declaration // 'struct'
|
||||
| enum_declaration // 'enum'
|
||||
| delegate_declaration // 'delegate'
|
||||
| conversion_operator_declaration
|
||||
| constructor_declaration // | static_constructor_declaration
|
||||
)
|
||||
;
|
||||
// struct_modifiers:
|
||||
// struct_modifier+ ;
|
||||
// struct_modifier:
|
||||
// 'new' | 'public' | 'protected' | 'internal' | 'private' | 'unsafe' ;
|
||||
// struct_interfaces:
|
||||
// ':' interface_type_list;
|
||||
// struct_body:
|
||||
// '{' struct_member_declarations? '}';
|
||||
// struct_member_declarations:
|
||||
// struct_member_declaration+ ;
|
||||
// struct_member_declaration:
|
||||
// attributes? m=modifiers?
|
||||
// ( 'const' type constant_declarators ';'
|
||||
// | event_declaration // 'event'
|
||||
// | p='partial' { Warning($p.line, "[UNSUPPORTED] 'partial' definition"); } (v1=void_type method_declaration[$attributes.tree, $modifiers.tree, $v1.tree]
|
||||
// | interface_declaration
|
||||
// | class_declaration
|
||||
// | struct_declaration)
|
||||
//
|
||||
// | interface_declaration // 'interface'
|
||||
// | class_declaration // 'class'
|
||||
// | v2=void_type method_declaration[$attributes.tree, $modifiers.tree, $v2.tree]
|
||||
// | t1=type ( (member_name type_parameter_list? '(') => method_declaration[$attributes.tree, $modifiers.tree, $t1.tree]
|
||||
// | (member_name '{') => property_declaration
|
||||
// | (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||
// | indexer_declaration //this
|
||||
// | field_declaration // qid
|
||||
// | operator_declaration
|
||||
// )
|
||||
// // common_modifiers// (method_modifiers | field_modifiers)
|
||||
//
|
||||
// | struct_declaration // 'struct'
|
||||
// | enum_declaration // 'enum'
|
||||
// | delegate_declaration // 'delegate'
|
||||
// | conversion_operator_declaration
|
||||
// | constructor_declaration // | static_constructor_declaration
|
||||
// )
|
||||
// ;
|
||||
// UNUSED END
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
indexer_declaration:
|
||||
indexer_declarator '{' accessor_declarations '}' ;
|
||||
indexer_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
||||
indexer_declarator '{' accessor_declarations[atts, mods, type, "INDEX", "INDEX"] '}' ;
|
||||
indexer_declarator:
|
||||
//(type_name '.')?
|
||||
'this' '[' formal_parameter_list ']' ;
|
||||
@ -1302,3 +1312,31 @@ magicThrowableType:
|
||||
|
||||
magicCatchVar:
|
||||
-> IDENTIFIER["__dummyCatchVar" + dummyCatchVarCtr++];
|
||||
|
||||
magicPropGetter[CommonTree atts, CommonTree localatts, CommonTree mods, CommonTree localmods, CommonTree type, IToken getTok, CommonTree body, String propName, bool mkBody, String varName]
|
||||
@init {
|
||||
CommonTree realBody = body;
|
||||
}:
|
||||
( { mkBody }? => b=magicGetterBody[getTok,varName] { realBody = $b.tree; }| )
|
||||
-> ^(METHOD[$type.token, "METHOD"] { dupTree(mods) } { dupTree(type)} IDENTIFIER[getTok, "get"+propName] { dupTree(realBody) } )
|
||||
;
|
||||
magicPropSetter[CommonTree atts, CommonTree localatts, CommonTree mods, CommonTree localmods, CommonTree type, IToken setTok, CommonTree body, String propName, bool mkBody, String varName]
|
||||
@init {
|
||||
CommonTree realBody = body;
|
||||
}:
|
||||
( { mkBody }? => b=magicSetterBody[setTok,varName] { realBody = $b.tree; }| )
|
||||
-> ^(METHOD[$type.token, "METHOD"] { dupTree(mods) } ^(TYPE[setTok, "TYPE"] IDENTIFIER[setTok, "void"] ) IDENTIFIER[setTok, "set"+propName] ^(PARAMS[setTok, "PARAMS"] { dupTree(type)} IDENTIFIER[setTok, "value"]) { dupTree(realBody) } )
|
||||
;
|
||||
|
||||
magicSemi:
|
||||
-> SEMI;
|
||||
|
||||
magicMkPropertyVar[CommonTree type, String varText] :
|
||||
-> ^(FIELD[$type.token, "FIELD"] PRIVATE[$type.token, "private"] { dupTree(type) } IDENTIFIER[$type.token, varText])
|
||||
;
|
||||
|
||||
magicGetterBody[IToken getTok, String varName]:
|
||||
-> OPEN_BRACE[getTok,"{"] ^(RETURN[getTok, "return"] IDENTIFIER[getTok, varName]) CLOSE_BRACE[getTok,"}"];
|
||||
magicSetterBody[IToken setTok, String varName]:
|
||||
-> OPEN_BRACE[setTok,"{"] IDENTIFIER[setTok, varName] ASSIGN[setTok,"="] IDENTIFIER[setTok, "value"] SEMI[setTok, ";"] CLOSE_BRACE[setTok,"}"] ;
|
||||
|
||||
|
@ -232,7 +232,6 @@ compilation_unit
|
||||
|
||||
type_declaration [StringTemplate modifiersST]:
|
||||
class_declaration[modifiersST] -> { $class_declaration.st }
|
||||
// | struct_declaration
|
||||
| interface_declaration[modifiersST] -> { $interface_declaration.st }
|
||||
| enum_declaration[modifiersST] -> { $enum_declaration.st }
|
||||
| delegate_declaration ;
|
||||
@ -251,20 +250,19 @@ modifier
|
||||
-> string(payload={$m.text});
|
||||
|
||||
class_member_declaration returns [List<String> preComments]:
|
||||
^(CONST attributes? modifiers? type constant_declarators)
|
||||
| ^(EVENT attributes? modifiers? event_declaration)
|
||||
^(CONST attributes? modifiers? type { $preComments = CollectedComments; } constant_declarators)
|
||||
| ^(EVENT attributes? modifiers? { $preComments = CollectedComments; } event_declaration)
|
||||
| ^(METHOD attributes? modifiers? type member_name type_parameter_constraints_clauses? type_parameter_list[$type_parameter_constraints_clauses.tpConstraints]? formal_parameter_list?
|
||||
{ $preComments = CollectedComments; } method_body)
|
||||
-> method(modifiers={$modifiers.st}, type={$type.st}, name={ $member_name.st }, typeparams = { $type_parameter_list.st }, params={ $formal_parameter_list.st }, bodyIsSemi = { $method_body.isSemi }, body={ $method_body.st })
|
||||
// | ^(METHOD attributes? modifiers? type method_declaration) -> method(modifiers={$modifiers.st}, type={$type.st}, method={$method_declaration.st})
|
||||
| ^(INTERFACE attributes? modifiers? interface_declaration[$modifiers.st]) -> { $interface_declaration.st }
|
||||
| ^(CLASS attributes? modifiers? class_declaration[$modifiers.st]) -> { $class_declaration.st }
|
||||
| ^(PROPERTY attributes? modifiers? type property_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||
| ^(FIELD attributes? modifiers? type field_declaration) -> field(modifiers={$modifiers.st}, type={$type.st}, field={$field_declaration.st})
|
||||
| ^(OPERATOR attributes? modifiers? type operator_declaration)
|
||||
| ^(ENUM attributes? modifiers? enum_declaration[$modifiers.st])
|
||||
| ^(DELEGATE attributes? modifiers? delegate_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? { $preComments = CollectedComments; } indexer_declaration)
|
||||
| ^(FIELD attributes? modifiers? type { $preComments = CollectedComments; } field_declaration) -> field(modifiers={$modifiers.st}, type={$type.st}, field={$field_declaration.st})
|
||||
| ^(OPERATOR attributes? modifiers? type { $preComments = CollectedComments; } operator_declaration)
|
||||
| ^(ENUM attributes? modifiers? { $preComments = CollectedComments; } enum_declaration[$modifiers.st])
|
||||
| ^(DELEGATE attributes? modifiers? { $preComments = CollectedComments; } delegate_declaration)
|
||||
| ^(CONVERSION_OPERATOR attributes? modifiers? conversion_operator_declaration)
|
||||
| ^(CONSTRUCTOR attributes? modifiers? constructor_declaration)
|
||||
| ^(DESTRUCTOR attributes? modifiers? destructor_declaration)
|
||||
@ -847,7 +845,7 @@ constant_expression:
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
field_declaration:
|
||||
variable_declarators ';' -> { $variable_declarators.st };
|
||||
variable_declarators -> { $variable_declarators.st };
|
||||
variable_declarators:
|
||||
vs+=variable_declarator (',' vs+=variable_declarator)* -> variable_declarators(varinits = {$vs});
|
||||
variable_declarator:
|
||||
@ -870,8 +868,7 @@ member_name:
|
||||
// qid -> { $qid.st }; // IInterface<int>.Method logic added.
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
property_declaration:
|
||||
member_name '{' accessor_declarations '}' ;
|
||||
|
||||
accessor_declarations:
|
||||
attributes?
|
||||
(get_accessor_declaration attributes? set_accessor_declaration?
|
||||
@ -996,11 +993,9 @@ interface_member_declaration returns [List<String> preComments]:
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list[$type_parameter_constraints_clauses.tpConstraints]? formal_parameter_list?)
|
||||
{ $preComments = CollectedComments; }
|
||||
-> method(modifiers={$modifiers.st}, type={$type.st}, name={ $identifier.st }, typeparams = { $type_parameter_list.st }, params={ $formal_parameter_list.st }, bodyIsSemi = { true })
|
||||
| ^(PROPERTY attributes? modifiers? type property_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? { $preComments = CollectedComments; } indexer_declaration)
|
||||
;
|
||||
interface_property_declaration:
|
||||
identifier '{' interface_accessor_declarations '}' ;
|
||||
|
||||
interface_method_declaration:
|
||||
identifier generic_argument_list?
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ';' ;
|
||||
|
@ -19,7 +19,6 @@ compilation_unit:
|
||||
|
||||
type_declaration:
|
||||
class_declaration
|
||||
| struct_declaration
|
||||
| interface_declaration
|
||||
| enum_declaration
|
||||
| delegate_declaration ;
|
||||
@ -41,7 +40,6 @@ class_member_declaration:
|
||||
| ^(METHOD attributes? modifiers? type member_name type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? method_body)
|
||||
| ^(INTERFACE attributes? modifiers? interface_declaration)
|
||||
| ^(CLASS attributes? modifiers? class_declaration)
|
||||
| ^(PROPERTY attributes? modifiers? type property_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||
| ^(FIELD attributes? modifiers? type field_declaration)
|
||||
| ^(OPERATOR attributes? modifiers? type operator_declaration)
|
||||
@ -588,7 +586,7 @@ constant_expression:
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
field_declaration:
|
||||
variable_declarators ';' ;
|
||||
variable_declarators ;
|
||||
variable_declarators:
|
||||
variable_declarator (',' variable_declarator)* ;
|
||||
variable_declarator:
|
||||
@ -608,22 +606,22 @@ member_name:
|
||||
//identifier ; // IInterface<int>.Method logic added.
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
property_declaration:
|
||||
member_name '{' accessor_declarations '}' ;
|
||||
|
||||
accessor_declarations:
|
||||
attributes?
|
||||
(get_accessor_declaration attributes? set_accessor_declaration?
|
||||
| set_accessor_declaration attributes? get_accessor_declaration?) ;
|
||||
attributes?
|
||||
(get_accessor_declaration attributes? set_accessor_declaration?
|
||||
| set_accessor_declaration attributes? get_accessor_declaration?) ;
|
||||
get_accessor_declaration:
|
||||
accessor_modifier? 'get' accessor_body ;
|
||||
accessor_modifier? 'get' accessor_body ;
|
||||
set_accessor_declaration:
|
||||
accessor_modifier? 'set' accessor_body ;
|
||||
accessor_modifier? 'set' accessor_body ;
|
||||
accessor_modifier:
|
||||
'public' | 'protected' | 'private' | 'internal' ;
|
||||
'public' | 'protected' | 'private' | 'internal' ;
|
||||
accessor_body:
|
||||
block ;
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
||||
event_declaration:
|
||||
'event' type
|
||||
((member_name '{') => member_name '{' event_accessor_declarations '}'
|
||||
@ -718,11 +716,8 @@ interface_member_declarations:
|
||||
interface_member_declaration:
|
||||
^(EVENT attributes? modifiers? event_declaration)
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list?)
|
||||
| ^(PROPERTY attributes? modifiers? type property_declaration)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||
;
|
||||
interface_property_declaration:
|
||||
identifier '{' interface_accessor_declarations '}' ;
|
||||
interface_method_declaration:
|
||||
identifier generic_argument_list?
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ';' ;
|
||||
@ -744,46 +739,46 @@ method_modifiers:
|
||||
modifier+ ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
struct_declaration:
|
||||
'struct' type_or_generic struct_interfaces? type_parameter_constraints_clauses? struct_body ';'? ;
|
||||
struct_modifiers:
|
||||
struct_modifier+ ;
|
||||
struct_modifier:
|
||||
'new' | 'public' | 'protected' | 'internal' | 'private' | 'unsafe' ;
|
||||
struct_interfaces:
|
||||
':' interface_type_list;
|
||||
struct_body:
|
||||
'{' struct_member_declarations? '}';
|
||||
struct_member_declarations:
|
||||
struct_member_declaration+ ;
|
||||
struct_member_declaration:
|
||||
attributes? m=modifiers?
|
||||
( 'const' type constant_declarators ';'
|
||||
| event_declaration // 'event'
|
||||
| 'partial' (method_declaration
|
||||
| interface_declaration
|
||||
| class_declaration
|
||||
| struct_declaration)
|
||||
|
||||
| interface_declaration // 'interface'
|
||||
| class_declaration // 'class'
|
||||
| 'void' method_declaration
|
||||
| type ( (member_name '(') => method_declaration
|
||||
| (member_name '{') => property_declaration
|
||||
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||
| indexer_declaration //this
|
||||
| field_declaration // qid
|
||||
| operator_declaration
|
||||
)
|
||||
// common_modifiers// (method_modifiers | field_modifiers)
|
||||
|
||||
| struct_declaration // 'struct'
|
||||
| enum_declaration // 'enum'
|
||||
| delegate_declaration // 'delegate'
|
||||
| conversion_operator_declaration
|
||||
| constructor_declaration // | static_constructor_declaration
|
||||
)
|
||||
;
|
||||
// struct_declaration:
|
||||
// 'struct' type_or_generic struct_interfaces? type_parameter_constraints_clauses? struct_body ';'? ;
|
||||
// struct_modifiers:
|
||||
// struct_modifier+ ;
|
||||
// struct_modifier:
|
||||
// 'new' | 'public' | 'protected' | 'internal' | 'private' | 'unsafe' ;
|
||||
// struct_interfaces:
|
||||
// ':' interface_type_list;
|
||||
// struct_body:
|
||||
// '{' struct_member_declarations? '}';
|
||||
// struct_member_declarations:
|
||||
// struct_member_declaration+ ;
|
||||
// struct_member_declaration:
|
||||
// attributes? m=modifiers?
|
||||
// ( 'const' type constant_declarators ';'
|
||||
// | event_declaration // 'event'
|
||||
// | 'partial' (method_declaration
|
||||
// | interface_declaration
|
||||
// | class_declaration
|
||||
// | struct_declaration)
|
||||
//
|
||||
// | interface_declaration // 'interface'
|
||||
// | class_declaration // 'class'
|
||||
// | 'void' method_declaration
|
||||
// | type ( (member_name '(') => method_declaration
|
||||
// | (member_name '{') => property_declaration
|
||||
// | (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||
// | indexer_declaration //this
|
||||
// | field_declaration // qid
|
||||
// | operator_declaration
|
||||
// )
|
||||
// // common_modifiers// (method_modifiers | field_modifiers)
|
||||
//
|
||||
// | struct_declaration // 'struct'
|
||||
// | enum_declaration // 'enum'
|
||||
// | delegate_declaration // 'delegate'
|
||||
// | conversion_operator_declaration
|
||||
// | constructor_declaration // | static_constructor_declaration
|
||||
// )
|
||||
// ;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
|
@ -47,8 +47,13 @@ tokens {
|
||||
ARGS;
|
||||
NEW;
|
||||
|
||||
RETURN = 'return';
|
||||
PRIVATE = 'private';
|
||||
|
||||
OPEN_BRACKET='[';
|
||||
CLOSE_BRACKET=']';
|
||||
OPEN_BRACE='{';
|
||||
CLOSE_BRACE='}';
|
||||
LPAREN='(';
|
||||
NULL_COALESCE='??';
|
||||
IF='if';
|
||||
|
Loading…
x
Reference in New Issue
Block a user