mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Implement ?? operator (assumes we can call the expression multiple times ....) add throws Exception to methods and interface methods
This commit is contained in:
parent
7f3951aff0
commit
f1c9c5e6aa
@ -622,7 +622,11 @@ conditional_or_expression:
|
||||
conditional_and_expression ('||'^ conditional_and_expression)* ;
|
||||
|
||||
null_coalescing_expression:
|
||||
conditional_or_expression ('??'^ conditional_or_expression)* ;
|
||||
(e1=conditional_or_expression -> $e1) (qq='??' e2=conditional_or_expression -> ^(COND_EXPR[$qq.token, "?:"]
|
||||
^(NOT_EQUAL[$qq.token, "!="] { dupTree($null_coalescing_expression.tree) } NULL[$qq.Token, "null"])
|
||||
{ dupTree($null_coalescing_expression.tree) }
|
||||
{ dupTree($e2.tree) })
|
||||
)* ;
|
||||
conditional_expression:
|
||||
(ne=null_coalescing_expression -> $ne) (q='?' te=expression ':' ee=expression -> ^(COND_EXPR[$q.token, "?:"] $conditional_expression $te $ee))? ;
|
||||
// (null_coalescing_expression '?' expression ':') => e1=null_coalescing_expression q='?' e2=expression ':' e3=expression -> ^(COND_EXPR[$q.token, "?:"] $e1 $e2 $e3)
|
||||
@ -1072,9 +1076,9 @@ interface_property_declaration [CommonTree atts, CommonTree mods, CommonTree typ
|
||||
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? ';'
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? magicThrowable ';'
|
||||
-> ^(METHOD { dupTree($atts) } { dupTree($mods) } { dupTree($type) }
|
||||
identifier type_parameter_constraints_clauses? generic_argument_list? formal_parameter_list?);
|
||||
identifier type_parameter_constraints_clauses? generic_argument_list? formal_parameter_list? magicThrowable);
|
||||
interface_event_declaration [CommonTree atts, CommonTree mods]:
|
||||
//attributes? 'new'?
|
||||
'event' type identifier ';' ;
|
||||
@ -1449,16 +1453,18 @@ magicCatchVar:
|
||||
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;
|
||||
CommonTree exceptionList = null;
|
||||
}:
|
||||
( { mkBody }? => b=magicGetterBody[getTok,varName] { realBody = $b.tree; }| )
|
||||
-> ^(METHOD[$type.token, "METHOD"] { dupTree(mods) } { dupTree(type)} IDENTIFIER[getTok, "get"+propName] { dupTree(realBody) } )
|
||||
( { mkBody }? => b=magicGetterBody[getTok,varName] { realBody = $b.tree; } | e=magicException { exceptionList = $e.tree; })
|
||||
-> ^(METHOD[$type.token, "METHOD"] { dupTree(mods) } { dupTree(type)} IDENTIFIER[getTok, "get"+propName] { dupTree(realBody) } { exceptionList })
|
||||
;
|
||||
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;
|
||||
CommonTree exceptionList = null;
|
||||
}:
|
||||
( { 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) } )
|
||||
( { mkBody }? => b=magicSetterBody[setTok,varName] { realBody = $b.tree; }| e=magicException { exceptionList = $e.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) } { exceptionList } )
|
||||
;
|
||||
|
||||
magicSemi:
|
||||
|
@ -257,7 +257,7 @@ class_member_declaration returns [List<String> preComments]:
|
||||
| ^(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 exception*)
|
||||
-> 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(modifiers={$modifiers.st}, type={$type.st}, name={ $member_name.st }, typeparams = { $type_parameter_list.st }, params={ $formal_parameter_list.st }, exceptions = { $exception.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 }
|
||||
@ -1048,32 +1048,12 @@ interface_member_declaration_aux:
|
||||
|
||||
interface_member_declaration returns [List<String> preComments]:
|
||||
^(EVENT attributes? modifiers? event_declaration)
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list[$type_parameter_constraints_clauses.tpConstraints]? formal_parameter_list?)
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list[$type_parameter_constraints_clauses.tpConstraints]? formal_parameter_list? exception*)
|
||||
{ $preComments = CollectedComments; }
|
||||
-> method(modifiers={$modifiers.st}, type={$type.st}, name={ $identifier.st }, typeparams = { $type_parameter_list.st }, params={ $formal_parameter_list.st }, bodyIsSemi = { true })
|
||||
-> method(modifiers={$modifiers.st}, type={$type.st}, name={ $identifier.st }, typeparams = { $type_parameter_list.st }, params={ $formal_parameter_list.st }, exceptions= { $exception.st }, bodyIsSemi = { true })
|
||||
| ^(INDEXER attributes? modifiers? type type_name? { $preComments = CollectedComments; } indexer_declaration)
|
||||
;
|
||||
|
||||
interface_method_declaration:
|
||||
identifier generic_argument_list?
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ';' ;
|
||||
interface_event_declaration:
|
||||
//attributes? 'new'?
|
||||
'event' type identifier ';' ;
|
||||
interface_indexer_declaration:
|
||||
// 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+ ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// struct_declaration:
|
||||
// 'struct' type_or_generic struct_interfaces? type_parameter_constraints_clauses? struct_body ';'? ;
|
||||
|
@ -719,28 +719,9 @@ interface_member_declarations:
|
||||
interface_member_declaration+ ;
|
||||
interface_member_declaration:
|
||||
^(EVENT attributes? modifiers? event_declaration)
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list?)
|
||||
| ^(METHOD attributes? modifiers? type identifier type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? exception*)
|
||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||
;
|
||||
interface_method_declaration:
|
||||
identifier generic_argument_list?
|
||||
'(' formal_parameter_list? ')' type_parameter_constraints_clauses? ';' ;
|
||||
interface_event_declaration:
|
||||
//attributes? 'new'?
|
||||
'event' type identifier ';' ;
|
||||
interface_indexer_declaration:
|
||||
// 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+ ;
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// struct_declaration:
|
||||
|
Loading…
x
Reference in New Issue
Block a user