mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
varargs support
This commit is contained in:
parent
19bf099ae4
commit
710d887c7b
@ -16,6 +16,16 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
: base(input, state)
|
: base(input, state)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
protected void Error(int line, String s)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("{0}({1}) error: {2}", Filename, line, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Error(String s)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("{0} error: {1}", Filename, s);
|
||||||
|
}
|
||||||
|
|
||||||
protected void Warning(int line, String s)
|
protected void Warning(int line, String s)
|
||||||
{
|
{
|
||||||
if (Cfg.Warnings)
|
if (Cfg.Warnings)
|
||||||
|
@ -1001,7 +1001,23 @@ default_argument:
|
|||||||
parameter_modifier:
|
parameter_modifier:
|
||||||
'ref' | 'out' | 'this' ;
|
'ref' | 'out' | 'this' ;
|
||||||
parameter_array:
|
parameter_array:
|
||||||
'params' type identifier ;
|
p='params'^ t=type identifier
|
||||||
|
{
|
||||||
|
// type will be an array, need to strip the final [] for java
|
||||||
|
int numComponents = adaptor.GetChildCount($t.tree);
|
||||||
|
// sanity check
|
||||||
|
if (numComponents >= 3 &&
|
||||||
|
adaptor.GetType(adaptor.GetChild($t.tree, numComponents-2)) == OPEN_BRACKET &&
|
||||||
|
adaptor.GetType(adaptor.GetChild($t.tree, numComponents-1)) == CLOSE_BRACKET)
|
||||||
|
{
|
||||||
|
adaptor.DeleteChild($t.tree, numComponents-1);
|
||||||
|
adaptor.DeleteChild($t.tree, numComponents-2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Error($p.line, "[SOURCE ERROR] params type must be an array");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
interface_declaration returns [string name]
|
interface_declaration returns [string name]
|
||||||
|
@ -987,7 +987,7 @@ return_type:
|
|||||||
formal_parameter_list:
|
formal_parameter_list:
|
||||||
^(PARAMS fps+=formal_parameter+) -> list(items= {$fps}, sep={", "});
|
^(PARAMS fps+=formal_parameter+) -> list(items= {$fps}, sep={", "});
|
||||||
formal_parameter:
|
formal_parameter:
|
||||||
attributes? (fixed_parameter -> { $fixed_parameter.st }| parameter_array)
|
attributes? (fixed_parameter -> { $fixed_parameter.st }| parameter_array -> { $parameter_array.st })
|
||||||
| '__arglist'; // __arglist is undocumented, see google
|
| '__arglist'; // __arglist is undocumented, see google
|
||||||
//fixed_parameters:
|
//fixed_parameters:
|
||||||
// fps+=fixed_parameter (',' fps+=fixed_parameter)* -> { $fps };
|
// fps+=fixed_parameter (',' fps+=fixed_parameter)* -> { $fps };
|
||||||
@ -1000,7 +1000,7 @@ default_argument:
|
|||||||
parameter_modifier:
|
parameter_modifier:
|
||||||
(m='ref' | m='out' | m='this') -> inline_comment(payload={ $m.text }, explanation={ "parameter modifiers are not yet supported" }) ;
|
(m='ref' | m='out' | m='this') -> inline_comment(payload={ $m.text }, explanation={ "parameter modifiers are not yet supported" }) ;
|
||||||
parameter_array:
|
parameter_array:
|
||||||
'params' type identifier ;
|
^('params' type identifier) -> varargs(type={ $type.st }, name = { $identifier.st }) ;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
interface_declaration[StringTemplate modifiersST]
|
interface_declaration[StringTemplate modifiersST]
|
||||||
|
@ -703,7 +703,7 @@ default_argument:
|
|||||||
parameter_modifier:
|
parameter_modifier:
|
||||||
'ref' | 'out' | 'this' ;
|
'ref' | 'out' | 'this' ;
|
||||||
parameter_array:
|
parameter_array:
|
||||||
'params' type identifier ;
|
^('params' type identifier) ;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
interface_declaration:
|
interface_declaration:
|
||||||
|
@ -80,6 +80,10 @@ fixed_parameter(mod,type,name,def) ::= <<
|
|||||||
<mod> <type> <name><if(def)> = <def><endif>
|
<mod> <type> <name><if(def)> = <def><endif>
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
varargs(type,name) ::= <<
|
||||||
|
<type>... <name>
|
||||||
|
>>
|
||||||
|
|
||||||
identifier(id, id2) ::= "<id><if(id2)>::<id2><endif>"
|
identifier(id, id2) ::= "<id><if(id2)>::<id2><endif>"
|
||||||
|
|
||||||
statement_list(statements) ::= <<
|
statement_list(statements) ::= <<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user