mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
emit constructors
This commit is contained in:
parent
8a9eea3fcc
commit
401716aaa1
@ -1045,13 +1045,16 @@ operator_body:
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
constructor_declaration:
|
||||
constructor_declarator constructor_body ;
|
||||
constructor_declarator:
|
||||
identifier '(' formal_parameter_list? ')' constructor_initializer? ;
|
||||
i=identifier '(' p=formal_parameter_list? ')' init=constructor_initializer? b=constructor_body[$init.tree]
|
||||
-> $i $p? $b;
|
||||
constructor_initializer:
|
||||
':' ('base' | 'this') '(' argument_list? ')' ;
|
||||
constructor_body:
|
||||
block ;
|
||||
':' (tok='base' { tok.Text = "super"; } | tok='this') '(' argument_list? ')'
|
||||
-> ^(APPLY[$tok.token, "APPLY"] IDENTIFIER[$tok.token, $tok.token.Text] argument_list?) SEMI[$tok.token, ";"] ;
|
||||
constructor_body[CommonTree init]:
|
||||
{init == null}?=> s=';' -> $s
|
||||
| s1=';' -> OPEN_BRACE[$s1.token, "{"] { dupTree(init) } CLOSE_BRACE[$s1.token, "}"]
|
||||
| a='{' ss+=statement* b='}' -> $a { dupTree(init) } $ss* $b
|
||||
;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
//static_constructor_declaration:
|
||||
|
@ -264,7 +264,8 @@ class_member_declaration returns [List<String> preComments]:
|
||||
| ^(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)
|
||||
| ^(CONSTRUCTOR attributes? modifiers? identifier formal_parameter_list? { $preComments = CollectedComments; } block)
|
||||
-> constructor(modifiers={$modifiers.st}, name={ $identifier.st }, params={ $formal_parameter_list.st }, bodyIsSemi = { $block.isSemi }, body={ $block.st })
|
||||
| ^(DESTRUCTOR attributes? modifiers? destructor_declaration)
|
||||
;
|
||||
|
||||
@ -1091,16 +1092,6 @@ conversion_operator_declarator:
|
||||
operator_body:
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
constructor_declaration:
|
||||
constructor_declarator constructor_body ;
|
||||
constructor_declarator:
|
||||
identifier '(' formal_parameter_list? ')' constructor_initializer? ;
|
||||
constructor_initializer:
|
||||
':' ('base' | 'this') '(' argument_list? ')' ;
|
||||
constructor_body:
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
//static_constructor_declaration:
|
||||
// identifier '(' ')' static_constructor_body ;
|
||||
|
@ -46,7 +46,7 @@ class_member_declaration:
|
||||
| ^(ENUM attributes? modifiers? enum_declaration)
|
||||
| ^(DELEGATE attributes? modifiers? delegate_declaration)
|
||||
| ^(CONVERSION_OPERATOR attributes? modifiers? conversion_operator_declaration)
|
||||
| ^(CONSTRUCTOR attributes? modifiers? constructor_declaration)
|
||||
| ^(CONSTRUCTOR attributes? modifiers? identifier formal_parameter_list? block)
|
||||
| ^(DESTRUCTOR attributes? modifiers? destructor_declaration)
|
||||
;
|
||||
// class_member_declaration:
|
||||
@ -813,16 +813,6 @@ conversion_operator_declarator:
|
||||
operator_body:
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
constructor_declaration:
|
||||
constructor_declarator constructor_body ;
|
||||
constructor_declarator:
|
||||
identifier '(' formal_parameter_list? ')' constructor_initializer? ;
|
||||
constructor_initializer:
|
||||
':' ('base' | 'this') '(' argument_list? ')' ;
|
||||
constructor_body:
|
||||
block ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
//static_constructor_declaration:
|
||||
// identifier '(' ')' static_constructor_body ;
|
||||
|
@ -53,10 +53,18 @@ class_member(comments, member) ::= <<
|
||||
<member>
|
||||
>>
|
||||
|
||||
constructor(modifiers, name, params, exception="Throwable", bodyIsSemi, body) ::= <<
|
||||
<modifiers(modifiers)><name>(<params; separator=", ">) throws <exception><if(!bodyIsSemi)> {<else>;<endif>
|
||||
<body>
|
||||
<if(!bodyIsSemi)>}<endif>
|
||||
|
||||
>>
|
||||
|
||||
method(modifiers, typeparams, type, name, params, exception="Throwable", bodyIsSemi, body) ::= <<
|
||||
<modifiers(modifiers)><typeparams> <type> <name>(<params; separator=", ">) throws <exception><if(!bodyIsSemi)> {<else>;<endif>
|
||||
<body>
|
||||
<if(!bodyIsSemi)>}<endif>
|
||||
|
||||
>>
|
||||
|
||||
field(modifiers, type, field, comments, init) ::= "<comments><modifiers(modifiers)><type> <field>;"
|
||||
|
Loading…
x
Reference in New Issue
Block a user