mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
support for translating classes into RepTranslations
This commit is contained in:
parent
24c2470528
commit
e5fb7faca4
@ -11,7 +11,10 @@ namespace cs2jTest.Various.Features.join.yield
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private int myInt;
|
public const int MY_IMPORTANT_INT = 23;
|
||||||
|
public const String MY_IMPORTANT_STRING = "Kevin";
|
||||||
|
|
||||||
|
private System.Collections.Generic.IDictionary<int,short> myDict;
|
||||||
|
|
||||||
public string TestRWProperty {get; set;}
|
public string TestRWProperty {get; set;}
|
||||||
|
|
||||||
@ -19,6 +22,10 @@ namespace cs2jTest.Various.Features.join.yield
|
|||||||
return "hello";
|
return "hello";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string testgen<T>(T i) {
|
||||||
|
return "hello";
|
||||||
|
}
|
||||||
|
|
||||||
private string _testROProperty = null;
|
private string _testROProperty = null;
|
||||||
public string TestROProperty {
|
public string TestROProperty {
|
||||||
get { return _testROProperty; }
|
get { return _testROProperty; }
|
||||||
|
@ -47,8 +47,6 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
if (Processing.Peek() == false)
|
if (Processing.Peek() == false)
|
||||||
state.token = Token.SKIP_TOKEN;
|
state.token = Token.SKIP_TOKEN;
|
||||||
else
|
|
||||||
state.token = state.token;
|
|
||||||
}
|
}
|
||||||
else if (Warn)
|
else if (Warn)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// SignatureExtracter.g
|
// TemplateExtracter.g
|
||||||
//
|
//
|
||||||
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
|
// Crawler that extracts the signatures (typereptemplates) from a CSharp AST
|
||||||
//
|
//
|
||||||
@ -21,6 +21,7 @@ options {
|
|||||||
scope NSContext {
|
scope NSContext {
|
||||||
IList<UseRepTemplate> nss;
|
IList<UseRepTemplate> nss;
|
||||||
string currentNS;
|
string currentNS;
|
||||||
|
TypeRepTemplate currentTypeRep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@namespace { RusticiSoftware.Translator.CSharp }
|
@namespace { RusticiSoftware.Translator.CSharp }
|
||||||
@ -83,6 +84,7 @@ scope NSContext;
|
|||||||
// For initial, file level scope
|
// For initial, file level scope
|
||||||
$NSContext::nss = new List<UseRepTemplate>();
|
$NSContext::nss = new List<UseRepTemplate>();
|
||||||
$NSContext::currentNS = "";
|
$NSContext::currentNS = "";
|
||||||
|
$NSContext::currentTypeRep = null;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
{ Debug("start template extraction"); }
|
{ Debug("start template extraction"); }
|
||||||
@ -94,6 +96,7 @@ namespace_declaration
|
|||||||
scope NSContext;
|
scope NSContext;
|
||||||
@init{
|
@init{
|
||||||
$NSContext::nss = new List<UseRepTemplate>();
|
$NSContext::nss = new List<UseRepTemplate>();
|
||||||
|
$NSContext::currentTypeRep = null;
|
||||||
}
|
}
|
||||||
:
|
:
|
||||||
'namespace' qi=qualified_identifier
|
'namespace' qi=qualified_identifier
|
||||||
@ -110,7 +113,7 @@ namespace_body:
|
|||||||
extern_alias_directives:
|
extern_alias_directives:
|
||||||
extern_alias_directive+ ;
|
extern_alias_directive+ ;
|
||||||
extern_alias_directive:
|
extern_alias_directive:
|
||||||
'extern' 'alias' i=identifier ';' { Warning("UNSUPPORTED: External Alias " + $i.text); } ;
|
e='extern' 'alias' i=identifier ';' { Warning($e.line, "[UNSUPPORTED] External Alias " + $i.text); } ;
|
||||||
using_directives:
|
using_directives:
|
||||||
using_directive+ ;
|
using_directive+ ;
|
||||||
using_directive:
|
using_directive:
|
||||||
@ -130,7 +133,7 @@ namespace_member_declaration:
|
|||||||
namespace_declaration
|
namespace_declaration
|
||||||
| attributes? modifiers? type_declaration ;
|
| attributes? modifiers? type_declaration ;
|
||||||
type_declaration:
|
type_declaration:
|
||||||
('partial') => 'partial' { Warning("UNSUPPORTED: 'partial' definitions"); } (class_declaration
|
('partial') => p='partial' { Warning($p.line, "[UNSUPPORTED] 'partial' definition"); } (class_declaration
|
||||||
| struct_declaration
|
| struct_declaration
|
||||||
| interface_declaration)
|
| interface_declaration)
|
||||||
| class_declaration
|
| class_declaration
|
||||||
@ -154,20 +157,21 @@ modifier:
|
|||||||
|
|
||||||
class_member_declaration:
|
class_member_declaration:
|
||||||
attributes?
|
attributes?
|
||||||
|
// TODO: Don't emit private
|
||||||
m=modifiers?
|
m=modifiers?
|
||||||
( 'const' type constant_declarators ';'
|
( 'const' ct=type constant_declarators[$ct.thetext] ';'
|
||||||
| event_declaration // 'event'
|
| event_declaration // 'event'
|
||||||
| 'partial' (method_declaration
|
| p='partial' { Warning($p.line, "[UNSUPPORTED] 'partial' definition"); } (method_declaration["/* partial */"]
|
||||||
| interface_declaration
|
| interface_declaration
|
||||||
| class_declaration
|
| class_declaration
|
||||||
| struct_declaration)
|
| struct_declaration)
|
||||||
| interface_declaration // 'interface'
|
| interface_declaration // 'interface'
|
||||||
| 'void' method_declaration
|
| 'void' method_declaration["System.Void"]
|
||||||
| type ( (member_name '(') => method_declaration
|
| rt=type ( (member_name '(') => method_declaration[$rt.thetext]
|
||||||
| (member_name '{') => property_declaration
|
| (member_name '{') => property_declaration[$rt.thetext]
|
||||||
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||||
| indexer_declaration //this
|
| indexer_declaration //this
|
||||||
| field_declaration // qid
|
| field_declaration[$rt.thetext] // qid
|
||||||
| operator_declaration
|
| operator_declaration
|
||||||
)
|
)
|
||||||
// common_modifiers// (method_modifiers | field_modifiers)
|
// common_modifiers// (method_modifiers | field_modifiers)
|
||||||
@ -374,10 +378,10 @@ commas:
|
|||||||
// Type Section
|
// Type Section
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
|
|
||||||
type_name:
|
type_name returns [string thetext]:
|
||||||
namespace_or_type_name ;
|
namespace_or_type_name { $thetext = $namespace_or_type_name.text; };
|
||||||
namespace_or_type_name:
|
namespace_or_type_name:
|
||||||
type_or_generic ('::' type_or_generic)? ('.' type_or_generic)* ;
|
^(NS_OR_TN type_or_generic ^(CC type_or_generic?) type_or_generic*) ;
|
||||||
type_or_generic returns [string type, List<string> generic_arguments]
|
type_or_generic returns [string type, List<string> generic_arguments]
|
||||||
@init {
|
@init {
|
||||||
$generic_arguments = new List<String>();
|
$generic_arguments = new List<String>();
|
||||||
@ -388,16 +392,17 @@ type_or_generic returns [string type, List<string> generic_arguments]
|
|||||||
(identifier '<') => t=identifier ga=generic_argument_list { $generic_arguments = $ga.tyargs; }
|
(identifier '<') => t=identifier ga=generic_argument_list { $generic_arguments = $ga.tyargs; }
|
||||||
| t=identifier ;
|
| t=identifier ;
|
||||||
|
|
||||||
qid: // qualified_identifier v2
|
// keving: as far as I can see this is (<interfacename>.)?identifier (<tyargs>)? at lease for C# 3.0 and less.
|
||||||
qid_start qid_part*
|
qid returns [string name, List<String> tyargs]: // qualified_identifier v2
|
||||||
|
qid_start qid_part* { $name=$qid_start.name; $tyargs = $qid_start.tyargs; }
|
||||||
;
|
;
|
||||||
qid_start:
|
qid_start returns [string name, List<String> tyargs]:
|
||||||
predefined_type
|
predefined_type { $name = $predefined_type.thetext; }
|
||||||
| (identifier '<') => identifier generic_argument_list
|
| (identifier '<') => identifier generic_argument_list { $name = $identifier.text; $tyargs = $generic_argument_list.tyargs; }
|
||||||
// | 'this'
|
// | 'this'
|
||||||
// | 'base'
|
// | 'base'
|
||||||
| identifier ('::' identifier)?
|
| i1=identifier { $name = $i1.text; } ('::' inext=identifier { $name+="::" + $inext.text; })?
|
||||||
| literal
|
| literal { $name = $literal.text; }
|
||||||
; // 0.ToString() is legal
|
; // 0.ToString() is legal
|
||||||
|
|
||||||
|
|
||||||
@ -417,11 +422,11 @@ type_arguments returns [List<string> tyargs]
|
|||||||
:
|
:
|
||||||
t1=type { Debug("type arg: " + $t1.text); $tyargs.Add($t1.text); } (',' tn=type { Debug("type arg: " + $tn.text); $tyargs.Add($tn.text); })* ;
|
t1=type { Debug("type arg: " + $t1.text); $tyargs.Add($t1.text); } (',' tn=type { Debug("type arg: " + $tn.text); $tyargs.Add($tn.text); })* ;
|
||||||
|
|
||||||
type:
|
type returns [string thetext]:
|
||||||
^(TYPERS predefined_type? type_name? rank_specifiers '*'*)
|
((predefined_type | type_name) rank_specifiers) => (p1=predefined_type { $thetext = $p1.thetext; } | tn1=type_name { $thetext = $tn1.thetext; }) rs=rank_specifiers { $thetext += $rs.text; } ('*' { $thetext += "*"; })*
|
||||||
| ^(TYPEADORNED predefined_type? type_name? '*'* '?'?)
|
| ((predefined_type | type_name) ('*'+ | '?')) => (p2=predefined_type { $thetext = $p2.thetext; } | tn2=type_name { $thetext = $tn2.thetext; }) (('*' { $thetext += "*"; })+ | '?' { $thetext += "?"; })
|
||||||
| ^(TYPEBARE predefined_type? type_name?)
|
| (p3=predefined_type { $thetext = $p3.thetext; } | tn3=type_name { $thetext = $tn3.thetext; })
|
||||||
| ^(TYPEVOID '*'*)
|
| 'void' { $thetext = "System.Void"; } ('*' { $thetext += "*"; })+
|
||||||
;
|
;
|
||||||
non_nullable_type:
|
non_nullable_type:
|
||||||
(predefined_type | type_name)
|
(predefined_type | type_name)
|
||||||
@ -661,6 +666,7 @@ scope NSContext;
|
|||||||
// Nested types can see things in this space
|
// Nested types can see things in this space
|
||||||
$NSContext::nss.Add(new UseRepTemplate(klass.TypeName));
|
$NSContext::nss.Add(new UseRepTemplate(klass.TypeName));
|
||||||
$NSContext::currentNS = klass.TypeName;
|
$NSContext::currentNS = klass.TypeName;
|
||||||
|
$NSContext::currentTypeRep = klass;
|
||||||
AppEnv[klass.TypeName] = klass;
|
AppEnv[klass.TypeName] = klass;
|
||||||
}
|
}
|
||||||
(cb=class_base { klass.Inherits = $cb.typeList.ToArray(); } )?
|
(cb=class_base { klass.Inherits = $cb.typeList.ToArray(); } )?
|
||||||
@ -689,39 +695,58 @@ class_member_declarations:
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
constant_declaration:
|
constant_declaration:
|
||||||
'const' type constant_declarators ';' ;
|
'const' type constant_declarators[$type.thetext] ';' ;
|
||||||
constant_declarators:
|
constant_declarators [string type]:
|
||||||
constant_declarator (',' constant_declarator)* ;
|
constant_declarator[$type] (',' constant_declarator[$type])* ;
|
||||||
constant_declarator:
|
constant_declarator [string type]:
|
||||||
identifier ('=' constant_expression)? ;
|
identifier { ((ClassRepTemplate)$NSContext::currentTypeRep).Fields.Add(new FieldRepTemplate($type, $identifier.text)); } ('=' constant_expression)? ;
|
||||||
constant_expression:
|
constant_expression:
|
||||||
expression;
|
expression;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
field_declaration:
|
field_declaration [string type]:
|
||||||
variable_declarators ';' ;
|
variable_declarators[$type, false] ';' ;
|
||||||
variable_declarators:
|
variable_declarators [string type, bool isEvent]:
|
||||||
variable_declarator (',' variable_declarator)* ;
|
variable_declarator[$type, $isEvent] (',' variable_declarator[$type, $isEvent])* ;
|
||||||
variable_declarator:
|
variable_declarator [string type, bool isEvent]:
|
||||||
type_name ('=' variable_initializer)? ; // eg. event EventHandler IInterface.VariableName = Foo;
|
type_name
|
||||||
|
{ FieldRepTemplate f = new FieldRepTemplate($type, $type_name.text);
|
||||||
|
if (isEvent) {
|
||||||
|
((ClassRepTemplate)$NSContext::currentTypeRep).Fields.Add(f);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
((ClassRepTemplate)$NSContext::currentTypeRep).Events.Add(f);
|
||||||
|
}; } ('=' variable_initializer)? ; // eg. event EventHandler IInterface.VariableName = Foo;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
method_declaration:
|
method_declaration [string returnType]:
|
||||||
method_header method_body ;
|
method_header[$returnType] method_body ;
|
||||||
method_header:
|
method_header [string returnType]:
|
||||||
member_name '(' formal_parameter_list? ')' type_parameter_constraints_clauses? ;
|
member_name '(' fpl=formal_parameter_list? ')'
|
||||||
|
{ ((InterfaceRepTemplate)$NSContext::currentTypeRep).Methods.Add(new MethodRepTemplate($returnType, $member_name.name, ($member_name.tyargs == null ? null : $member_name.tyargs.ToArray()), $fpl.paramlist)); }
|
||||||
|
type_parameter_constraints_clauses? ;
|
||||||
method_body:
|
method_body:
|
||||||
block ;
|
block ;
|
||||||
member_name:
|
member_name returns [string name, List<String> tyargs]:
|
||||||
qid ; // IInterface<int>.Method logic added.
|
qid { $name = $qid.name; $tyargs = $qid.tyargs; } ; // IInterface<int>.Method logic added.
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
property_declaration:
|
property_declaration[string type]:
|
||||||
member_name '{' accessor_declarations '}' ;
|
member_name '{' accessor_declarations '}'
|
||||||
accessor_declarations:
|
{ PropRepTemplate propRep = new PropRepTemplate($type, $member_name.name);
|
||||||
|
propRep.CanRead = $accessor_declarations.hasGetter;
|
||||||
|
propRep.CanWrite = $accessor_declarations.hasSetter;
|
||||||
|
((InterfaceRepTemplate)$NSContext::currentTypeRep).Properties.Add(propRep); }
|
||||||
|
;
|
||||||
|
accessor_declarations returns [bool hasGetter, bool hasSetter]
|
||||||
|
@int {
|
||||||
|
$hasSetter = false;
|
||||||
|
$hasGetter = false;
|
||||||
|
}
|
||||||
|
:
|
||||||
attributes?
|
attributes?
|
||||||
(get_accessor_declaration attributes? set_accessor_declaration?
|
(get_accessor_declaration { $hasGetter = true; } attributes? (set_accessor_declaration { $hasSetter = true; })?
|
||||||
| set_accessor_declaration attributes? get_accessor_declaration?) ;
|
| set_accessor_declaration { $hasSetter = true; } attributes? (get_accessor_declaration { $hasGetter = true; })?) ;
|
||||||
get_accessor_declaration:
|
get_accessor_declaration:
|
||||||
accessor_modifier? 'get' accessor_body ;
|
accessor_modifier? 'get' accessor_body ;
|
||||||
set_accessor_declaration:
|
set_accessor_declaration:
|
||||||
@ -735,7 +760,7 @@ accessor_body:
|
|||||||
event_declaration:
|
event_declaration:
|
||||||
'event' type
|
'event' type
|
||||||
((member_name '{') => member_name '{' event_accessor_declarations '}'
|
((member_name '{') => member_name '{' event_accessor_declarations '}'
|
||||||
| variable_declarators ';') // typename=foo;
|
| variable_declarators[$type.thetext, true] ';') // typename=foo;
|
||||||
;
|
;
|
||||||
event_modifiers:
|
event_modifiers:
|
||||||
modifier+ ;
|
modifier+ ;
|
||||||
@ -807,23 +832,33 @@ constructor_constraint:
|
|||||||
return_type:
|
return_type:
|
||||||
type
|
type
|
||||||
| 'void';
|
| 'void';
|
||||||
formal_parameter_list:
|
formal_parameter_list returns [List<ParamRepTemplate> paramlist]
|
||||||
formal_parameter (',' formal_parameter)* ;
|
@init {
|
||||||
formal_parameter:
|
$paramlist = new List<ParamRepTemplate>();
|
||||||
attributes? (fixed_parameter | parameter_array)
|
}:
|
||||||
| '__arglist'; // __arglist is undocumented, see google
|
p1=formal_parameter { $paramlist.Add($p1.param); } (',' pn=formal_parameter { $paramlist.Add($pn.param); })* ;
|
||||||
fixed_parameters:
|
formal_parameter returns [ParamRepTemplate param]:
|
||||||
fixed_parameter (',' fixed_parameter)* ;
|
attributes? (fp=fixed_parameter { $param = $fp.param; } | pa=parameter_array { $param = $pa.param; })
|
||||||
|
| a='__arglist' { Warning($a.line, "[UNSUPPORTED] __arglist"); } ; // __arglist is undocumented, see google
|
||||||
|
fixed_parameters returns [List<ParamRepTemplate> paramlist]
|
||||||
|
@init {
|
||||||
|
$paramlist = new List<ParamRepTemplate>();
|
||||||
|
}:
|
||||||
|
p1=fixed_parameter { $paramlist.Add($p1.param); } (',' pn=fixed_parameter { $paramlist.Add($pn.param); })* ;
|
||||||
// 4.0
|
// 4.0
|
||||||
fixed_parameter:
|
fixed_parameter returns [ParamRepTemplate param]
|
||||||
parameter_modifier? type identifier default_argument? ;
|
@init {
|
||||||
|
bool isByRef = false;
|
||||||
|
}
|
||||||
|
:
|
||||||
|
(pm=parameter_modifier { isByRef = ($pm.text == "ref" || $pm.text == "out"); })? t=type i=identifier { $param=new ParamRepTemplate($t.thetext, $i.text, isByRef); } default_argument? ;
|
||||||
// 4.0
|
// 4.0
|
||||||
default_argument:
|
default_argument:
|
||||||
'=' expression;
|
'=' expression;
|
||||||
parameter_modifier:
|
parameter_modifier:
|
||||||
'ref' | 'out' | 'this' ;
|
'ref' | 'out' | 'this' ;
|
||||||
parameter_array:
|
parameter_array returns [ParamRepTemplate param]:
|
||||||
'params' type identifier ;
|
'params' t=type i=identifier { $param=new ParamRepTemplate($t.thetext + "[]", $i.text, false); } ;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
interface_declaration:
|
interface_declaration:
|
||||||
@ -883,21 +918,21 @@ struct_member_declarations:
|
|||||||
struct_member_declaration+ ;
|
struct_member_declaration+ ;
|
||||||
struct_member_declaration:
|
struct_member_declaration:
|
||||||
attributes? m=modifiers?
|
attributes? m=modifiers?
|
||||||
( 'const' type constant_declarators ';'
|
( 'const' ct=type constant_declarators[$ct.thetext] ';'
|
||||||
| event_declaration // 'event'
|
| event_declaration // 'event'
|
||||||
| 'partial' (method_declaration
|
| 'partial' (method_declaration["/* partial */"]
|
||||||
| interface_declaration
|
| interface_declaration
|
||||||
| class_declaration
|
| class_declaration
|
||||||
| struct_declaration)
|
| struct_declaration)
|
||||||
|
|
||||||
| interface_declaration // 'interface'
|
| interface_declaration // 'interface'
|
||||||
| class_declaration // 'class'
|
| class_declaration // 'class'
|
||||||
| 'void' method_declaration
|
| 'void' method_declaration["System.Void"]
|
||||||
| type ( (member_name '(') => method_declaration
|
| rt=type ( (member_name '(') => method_declaration[$rt.thetext]
|
||||||
| (member_name '{') => property_declaration
|
| (member_name '{') => property_declaration[$rt.thetext]
|
||||||
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
| (member_name '.' 'this') => type_name '.' indexer_declaration
|
||||||
| indexer_declaration //this
|
| indexer_declaration //this
|
||||||
| field_declaration // qid
|
| field_declaration[$rt.thetext] // qid
|
||||||
| operator_declaration
|
| operator_declaration
|
||||||
)
|
)
|
||||||
// common_modifiers// (method_modifiers | field_modifiers)
|
// common_modifiers// (method_modifiers | field_modifiers)
|
||||||
@ -947,7 +982,9 @@ operator_body:
|
|||||||
constructor_declaration:
|
constructor_declaration:
|
||||||
constructor_declarator constructor_body ;
|
constructor_declarator constructor_body ;
|
||||||
constructor_declarator:
|
constructor_declarator:
|
||||||
identifier '(' formal_parameter_list? ')' constructor_initializer? ;
|
identifier '(' fpl=formal_parameter_list? ')' constructor_initializer?
|
||||||
|
{ ((ClassRepTemplate)$NSContext::currentTypeRep).Constructors.Add(new ConstructorRepTemplate($fpl.paramlist)); }
|
||||||
|
;
|
||||||
constructor_initializer:
|
constructor_initializer:
|
||||||
':' ('base' | 'this') '(' argument_list? ')' ;
|
':' ('base' | 'this') '(' argument_list? ')' ;
|
||||||
constructor_body:
|
constructor_body:
|
||||||
@ -1036,7 +1073,7 @@ local_variable_initializer:
|
|||||||
stackalloc_initializer:
|
stackalloc_initializer:
|
||||||
'stackalloc' unmanaged_type '[' expression ']' ;
|
'stackalloc' unmanaged_type '[' expression ']' ;
|
||||||
local_constant_declaration:
|
local_constant_declaration:
|
||||||
'const' type constant_declarators ;
|
'const' type constant_declarators[$type.thetext] ;
|
||||||
expression_statement:
|
expression_statement:
|
||||||
expression ';' ;
|
expression ';' ;
|
||||||
|
|
||||||
@ -1141,9 +1178,23 @@ yield_statement:
|
|||||||
// Lexar Section
|
// Lexar Section
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
|
|
||||||
predefined_type:
|
predefined_type returns [string thetext]:
|
||||||
'bool' | 'byte' | 'char' | 'decimal' | 'double' | 'float' | 'int' | 'long' | 'object' | 'sbyte'
|
'bool' { $thetext = "System.Boolean"; }
|
||||||
| 'short' | 'string' | 'uint' | 'ulong' | 'ushort' ;
|
| 'byte' { $thetext = "System.Byte"; }
|
||||||
|
| 'char' { $thetext = "System.Char"; }
|
||||||
|
| 'decimal' { $thetext = "System.Decimal"; }
|
||||||
|
| 'double' { $thetext = "System.Double"; }
|
||||||
|
| 'float' { $thetext = "System.Single"; }
|
||||||
|
| 'int' { $thetext = "System.Int32"; }
|
||||||
|
| 'long' { $thetext = "System.Int64"; }
|
||||||
|
| 'object' { $thetext = "System.Object"; }
|
||||||
|
| 'sbyte' { $thetext = "System.SByte"; }
|
||||||
|
| 'short' { $thetext = "System.Int16"; }
|
||||||
|
| 'string' { $thetext = "System.String"; }
|
||||||
|
| 'uint' { $thetext = "System.UInt32"; }
|
||||||
|
| 'ulong' { $thetext = "System.UInt64"; }
|
||||||
|
| 'ushort' { $thetext = "System.UInt16"; }
|
||||||
|
;
|
||||||
|
|
||||||
identifier:
|
identifier:
|
||||||
IDENTIFIER | 'add' | 'alias' | 'assembly' | 'module' | 'field' | 'method' | 'param' | 'property' | 'type'
|
IDENTIFIER | 'add' | 'alias' | 'assembly' | 'module' | 'field' | 'method' | 'param' | 'property' | 'type'
|
||||||
|
@ -9,7 +9,7 @@ options {
|
|||||||
|
|
||||||
tokens {
|
tokens {
|
||||||
QID;
|
QID;
|
||||||
TYPEBARE; TYPERS; TYPEADORNED; TYPEVOID;
|
NS_OR_TN; CC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@namespace { RusticiSoftware.Translator.CSharp }
|
@namespace { RusticiSoftware.Translator.CSharp }
|
||||||
@ -311,7 +311,7 @@ commas:
|
|||||||
type_name:
|
type_name:
|
||||||
namespace_or_type_name ;
|
namespace_or_type_name ;
|
||||||
namespace_or_type_name:
|
namespace_or_type_name:
|
||||||
type_or_generic ('::' type_or_generic)? ('.' type_or_generic)* ;
|
t1=type_or_generic ('::' t2=type_or_generic)? ('.' t3+=type_or_generic)* -> ^(NS_OR_TN $t1 ^(CC $t2?) $t3*);
|
||||||
type_or_generic:
|
type_or_generic:
|
||||||
(identifier '<') => identifier generic_argument_list
|
(identifier '<') => identifier generic_argument_list
|
||||||
| identifier ;
|
| identifier ;
|
||||||
@ -338,10 +338,10 @@ type_arguments:
|
|||||||
type (',' type)* ;
|
type (',' type)* ;
|
||||||
|
|
||||||
type:
|
type:
|
||||||
((predefined_type | type_name) rank_specifiers) => (predefined_type | type_name) rank_specifiers '*'* -> ^(TYPERS predefined_type? type_name? rank_specifiers '*'*)
|
((predefined_type | type_name) rank_specifiers) => (predefined_type | type_name) rank_specifiers '*'*
|
||||||
| ((predefined_type | type_name) ('*'+ | '?')) => (predefined_type | type_name) ('*'+ | '?') -> ^(TYPEADORNED predefined_type? type_name? '*'* '?'?)
|
| ((predefined_type | type_name) ('*'+ | '?')) => (predefined_type | type_name) ('*'+ | '?')
|
||||||
| (predefined_type | type_name) -> ^(TYPEBARE predefined_type? type_name?)
|
| (predefined_type | type_name)
|
||||||
| 'void' '*'+ -> ^(TYPEVOID '*'+)
|
| 'void' '*'+
|
||||||
;
|
;
|
||||||
non_nullable_type:
|
non_nullable_type:
|
||||||
(predefined_type | type_name)
|
(predefined_type | type_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user