mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
ToString() -> toString()
This commit is contained in:
parent
a9c0e5acc6
commit
71512e308f
@ -319,7 +319,7 @@ dim_separators
|
|||||||
|
|
||||||
delegate_creation_expression:
|
delegate_creation_expression:
|
||||||
// 'new'
|
// 'new'
|
||||||
t1=type_name '(' t2=type_name ')' -> ^(NEW[$t1.start.Token, "NEW"] ^(TYPE[$t1.start.Token, "TYPE"] $t1) ^(ARGS[$t2.start.Token, "ARGS"] $t2));
|
t1=type_name '(' t2=type_name ')' -> ^(NEW[$t1.start.Token, "new"] ^(TYPE[$t1.start.Token, "TYPE"] $t1) ^(ARGS[$t2.start.Token, "ARGS"] $t2));
|
||||||
anonymous_object_creation_expression:
|
anonymous_object_creation_expression:
|
||||||
// 'new'
|
// 'new'
|
||||||
anonymous_object_initializer ;
|
anonymous_object_initializer ;
|
||||||
@ -378,8 +378,8 @@ anonymous_function_parameter_modifier:
|
|||||||
object_creation_expression:
|
object_creation_expression:
|
||||||
// 'new'
|
// 'new'
|
||||||
type
|
type
|
||||||
( '(' argument_list? ')' o1=object_or_collection_initializer? -> ^(NEW[$type.start.Token, "NEW"] type argument_list? $o1?)
|
( '(' argument_list? ')' o1=object_or_collection_initializer? -> ^(NEW[$type.start.Token, "new"] type argument_list? $o1?)
|
||||||
| o2=object_or_collection_initializer -> ^(NEW[$type.start.Token, "NEW"] type $o2))
|
| o2=object_or_collection_initializer -> ^(NEW[$type.start.Token, "new"] type $o2))
|
||||||
;
|
;
|
||||||
object_or_collection_initializer:
|
object_or_collection_initializer:
|
||||||
'{' (object_initializer
|
'{' (object_initializer
|
||||||
@ -756,14 +756,27 @@ variable_declarator:
|
|||||||
type_name ('=' variable_initializer)? ; // eg. event EventHandler IInterface.VariableName = Foo;
|
type_name ('=' variable_initializer)? ; // eg. event EventHandler IInterface.VariableName = Foo;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
method_declaration [CommonTree atts, CommonTree mods, CommonTree type]:
|
method_declaration [CommonTree atts, CommonTree mods, CommonTree type]
|
||||||
member_name type_parameter_list? '(' formal_parameter_list? ')' type_parameter_constraints_clauses? method_body
|
@init {
|
||||||
|
bool isToString = false;
|
||||||
|
CommonTree exceptions = null;
|
||||||
|
}:
|
||||||
|
member_name { isToString = $member_name.text == "ToString"; } (type_parameter_list { isToString = false; })? '(' (formal_parameter_list { isToString = false; })? ')' ( type_parameter_constraints_clauses { isToString = false; })? b=method_body[isToString]
|
||||||
|
{ if (isToString) {
|
||||||
|
$member_name.tree.Token.Text = "toString";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exceptions = $b.exceptionList;
|
||||||
|
}
|
||||||
|
}
|
||||||
-> ^(METHOD { dupTree($atts) } { dupTree($mods) } { dupTree($type) }
|
-> ^(METHOD { dupTree($atts) } { dupTree($mods) } { dupTree($type) }
|
||||||
member_name type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? method_body);
|
member_name type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? $b { exceptions });
|
||||||
//method_header[CommonTree atts, CommonTree mods, CommonTree type]:
|
|
||||||
|
|
||||||
method_body:
|
method_body [bool smotherExceptions] returns [CommonTree exceptionList]:
|
||||||
block ;
|
b=block nb=magicSmotherExceptions[ dupTree($b.tree) ] el=magicThrowable { if (!smotherExceptions) $exceptionList=$el.tree; }
|
||||||
|
-> {smotherExceptions}? $nb
|
||||||
|
-> $b
|
||||||
|
;
|
||||||
member_name returns [String rawId]:
|
member_name returns [String rawId]:
|
||||||
(type_or_generic '.')* i=identifier { $rawId = $i.text; }
|
(type_or_generic '.')* i=identifier { $rawId = $i.text; }
|
||||||
// keving [interface_type.identifier] | type_name '.' identifier
|
// keving [interface_type.identifier] | type_name '.' identifier
|
||||||
@ -986,7 +999,7 @@ interface_accessor_declaration [CommonTree atts, CommonTree mods, CommonTree typ
|
|||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
struct_declaration returns [string name]:
|
struct_declaration returns [string name]:
|
||||||
c='struct' identifier type_parameter_list? { $name = mkTypeName($identifier.text, $type_parameter_list.names); } class_base? type_parameter_constraints_clauses? class_body ';'?
|
c='struct' identifier type_parameter_list? { $name = mkTypeName($identifier.text, $type_parameter_list.names); } class_base? type_parameter_constraints_clauses? class_body ';'?
|
||||||
-> ^(CLASS[$c.Token] identifier type_parameter_constraints_clauses? type_parameter_list? class_base? class_body );
|
-> ^(CLASS[$c.Token, "class"] identifier type_parameter_constraints_clauses? type_parameter_list? class_base? class_body );
|
||||||
|
|
||||||
// UNUSED, HOPEFULLY
|
// UNUSED, HOPEFULLY
|
||||||
// struct_modifiers:
|
// struct_modifiers:
|
||||||
@ -1364,3 +1377,21 @@ magicSetterBody[IToken setTok, String varName]:
|
|||||||
// keving: can't get this to work reasonably
|
// keving: can't get this to work reasonably
|
||||||
//magicMkConstModifiers[IToken tok, List<string> filter]:
|
//magicMkConstModifiers[IToken tok, List<string> filter]:
|
||||||
// ({ !filter.Contains("static") }?=> -> STATIC[tok, "static"] ) ( { !filter.Contains("public") }?=> -> $magicMkConstModifiers FINAL[tok, "final"] );
|
// ({ !filter.Contains("static") }?=> -> STATIC[tok, "static"] ) ( { !filter.Contains("public") }?=> -> $magicMkConstModifiers FINAL[tok, "final"] );
|
||||||
|
|
||||||
|
magicException:
|
||||||
|
-> EXCEPTION["Throwable"]
|
||||||
|
;
|
||||||
|
|
||||||
|
magicSmotherExceptions[CommonTree body]:
|
||||||
|
v=magicCatchVar
|
||||||
|
-> OPEN_BRACE["{"]
|
||||||
|
^(TRY["try"]
|
||||||
|
{ dupTree(body) }
|
||||||
|
^(CATCH["catch"] ^(TYPE["TYPE"] IDENTIFIER["Throwable"]) { dupTree($v.tree) }
|
||||||
|
OPEN_BRACE["{"] ^(THROW["throw"] ^(NEW["new"] ^(TYPE["TYPE"] IDENTIFIER["RuntimeException"]) ^(ARGS["ARGS"] { dupTree($v.tree) }))) CLOSE_BRACE["}"]))
|
||||||
|
CLOSE_BRACE["}"]
|
||||||
|
;
|
||||||
|
|
||||||
|
magicThrowable:
|
||||||
|
-> EXCEPTION["Throwable"]
|
||||||
|
;
|
||||||
|
@ -256,7 +256,7 @@ class_member_declaration returns [List<String> preComments]:
|
|||||||
^(CONST attributes? modifiers? type { $preComments = CollectedComments; } constant_declarators)
|
^(CONST attributes? modifiers? type { $preComments = CollectedComments; } constant_declarators)
|
||||||
| ^(EVENT attributes? modifiers? { $preComments = CollectedComments; } event_declaration)
|
| ^(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?
|
| ^(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)
|
{ $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 }, 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})
|
// | ^(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 }
|
| ^(INTERFACE attributes? modifiers? interface_declaration[$modifiers.st]) -> { $interface_declaration.st }
|
||||||
@ -302,6 +302,10 @@ class_member_declaration returns [List<String> preComments]:
|
|||||||
// )
|
// )
|
||||||
// ;
|
// ;
|
||||||
//
|
//
|
||||||
|
|
||||||
|
exception:
|
||||||
|
EXCEPTION -> string(payload = { $EXCEPTION.text });
|
||||||
|
|
||||||
primary_expression returns [int precedence]
|
primary_expression returns [int precedence]
|
||||||
@init {
|
@init {
|
||||||
$precedence = int.MaxValue;
|
$precedence = int.MaxValue;
|
||||||
|
@ -37,7 +37,7 @@ modifier:
|
|||||||
class_member_declaration:
|
class_member_declaration:
|
||||||
^(CONST attributes? modifiers? type constant_declarators)
|
^(CONST attributes? modifiers? type constant_declarators)
|
||||||
| ^(EVENT attributes? modifiers? event_declaration)
|
| ^(EVENT attributes? modifiers? event_declaration)
|
||||||
| ^(METHOD attributes? modifiers? type member_name type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? method_body)
|
| ^(METHOD attributes? modifiers? type member_name type_parameter_constraints_clauses? type_parameter_list? formal_parameter_list? method_body exception*)
|
||||||
| ^(INTERFACE attributes? modifiers? interface_declaration)
|
| ^(INTERFACE attributes? modifiers? interface_declaration)
|
||||||
| ^(CLASS attributes? modifiers? class_declaration)
|
| ^(CLASS attributes? modifiers? class_declaration)
|
||||||
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
| ^(INDEXER attributes? modifiers? type type_name? indexer_declaration)
|
||||||
@ -79,6 +79,10 @@ class_member_declaration:
|
|||||||
// )
|
// )
|
||||||
// ;
|
// ;
|
||||||
//
|
//
|
||||||
|
|
||||||
|
exception:
|
||||||
|
EXCEPTION;
|
||||||
|
|
||||||
primary_expression:
|
primary_expression:
|
||||||
^(INDEX expression expression_list?)
|
^(INDEX expression expression_list?)
|
||||||
| ^(APPLY expression argument_list?)
|
| ^(APPLY expression argument_list?)
|
||||||
|
@ -51,6 +51,9 @@ tokens {
|
|||||||
PRIVATE = 'private';
|
PRIVATE = 'private';
|
||||||
STATIC = 'static';
|
STATIC = 'static';
|
||||||
PRIVATE = 'private';
|
PRIVATE = 'private';
|
||||||
|
TRY = 'try';
|
||||||
|
CATCH = 'catch';
|
||||||
|
THROW = 'throw';
|
||||||
|
|
||||||
OPEN_BRACKET='[';
|
OPEN_BRACKET='[';
|
||||||
CLOSE_BRACKET=']';
|
CLOSE_BRACKET=']';
|
||||||
@ -111,6 +114,8 @@ tokens {
|
|||||||
UNARY_EXPR;
|
UNARY_EXPR;
|
||||||
CAST_EXPR;
|
CAST_EXPR;
|
||||||
|
|
||||||
|
EXCEPTION;
|
||||||
|
|
||||||
PAYLOAD; // carries arbitrary text for the output file
|
PAYLOAD; // carries arbitrary text for the output file
|
||||||
PAYLOAD_LIST;
|
PAYLOAD_LIST;
|
||||||
SEP;
|
SEP;
|
||||||
|
@ -60,8 +60,8 @@ constructor(modifiers, name, params, exception="Throwable", bodyIsSemi, body) ::
|
|||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
method(modifiers, typeparams, type, name, params, exception="Throwable", bodyIsSemi, body) ::= <<
|
method(modifiers, typeparams, type, name, params, exceptions, bodyIsSemi, body) ::= <<
|
||||||
<modifiers(modifiers)><typeparams> <type> <name>(<params; separator=", ">) throws <exception><if(!bodyIsSemi)> {<else>;<endif>
|
<modifiers(modifiers)><typeparams> <type> <name>(<params; separator=", ">)<if(exceptions)> throws <exceptions; separator=", "><endif><if(!bodyIsSemi)> {<else>;<endif>
|
||||||
<body>
|
<body>
|
||||||
<if(!bodyIsSemi)>}<endif>
|
<if(!bodyIsSemi)>}<endif>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user