1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

checkpoint: We can process all files in ScormEngine again :)

This commit is contained in:
Kevin Glynn 2010-12-03 18:23:52 +01:00
parent d0a695315a
commit 65658f5e06
5 changed files with 51 additions and 35 deletions

View File

@ -164,8 +164,6 @@ namespace RusticiSoftware.Translator.CSharp
double elapsedTime = ((DateTime.Now.Ticks - startTime) / TimeSpan.TicksPerMillisecond) / 1000.0;
if (cfg.Verbosity >= 1)
{
System.Console.Out.WriteLine("");
System.Console.Out.WriteLine("");
System.Console.Out.WriteLine("Total run time was {0} seconds.", elapsedTime);
}
}
@ -297,7 +295,6 @@ namespace RusticiSoftware.Translator.CSharp
{
string typeName = javaMaker.CUKeys[i];
CommonTree typeAST = javaMaker.CUMap[typeName];
Console.WriteLine (typeName);
string claName = typeName.Substring(typeName.LastIndexOf('.')+1);
string nsDir = typeName.Substring(0,typeName.LastIndexOf('.')).Replace('.', Path.DirectorySeparatorChar);
@ -474,9 +471,9 @@ namespace RusticiSoftware.Translator.CSharp
double elapsedTime = ((DateTime.Now.Ticks - startTime) / TimeSpan.TicksPerMillisecond) / 1000.0;
//System.Console.Out.WriteLine(writer.ToString());
System.Console.Out.WriteLine("");
System.Console.Out.WriteLine("");
System.Console.Out.WriteLine("Processed {0} in: {1} seconds.", fullName, elapsedTime);
System.Console.Out.WriteLine("");
System.Console.Out.WriteLine("");
}
}
}

View File

@ -81,6 +81,14 @@ scope NSContext {
}
return id;
}
protected CommonTree mkHole() {
return mkHole(null);
}
protected CommonTree mkHole(IToken tok) {
return (CommonTree)adaptor.Create(KGHOLE, tok, "KGHOLE");
}
}
/********************************************************************************************
@ -199,12 +207,12 @@ primary_expression:
| (primary_expression_start -> primary_expression_start) (pp3=primary_expression_part[$primary_expression.tree] -> $pp3 )*
// keving:TODO fixup
| 'new' ( (object_creation_expression ('.'|'->'|'[')) =>
object_creation_expression primary_expression_part[null]+ // new Foo(arg, arg).Member
(oc1=object_creation_expression -> $oc1) (pp4=primary_expression_part[ $primary_expression.tree ] -> $pp4 )+ // new Foo(arg, arg).Member
// try the simple one first, this has no argS and no expressions
// symantically could be object creation
| (delegate_creation_expression) => delegate_creation_expression// new FooDelegate (MyFunction)
| object_creation_expression
| anonymous_object_creation_expression) // new {int X, string Y}
| (delegate_creation_expression) => delegate_creation_expression -> delegate_creation_expression // new FooDelegate (MyFunction)
| oc2=object_creation_expression -> $oc2
| anonymous_object_creation_expression -> anonymous_object_creation_expression) // new {int X, string Y}
| sizeof_expression // sizeof (struct)
| checked_expression // checked (...
| unchecked_expression // unchecked {...}
@ -243,7 +251,7 @@ paren_expression:
arguments [CommonTree lhs]:
'(' argument_list? ')' -> ^(APPLY { (CommonTree)adaptor.DupTree($lhs) } argument_list?);
argument_list:
argument (',' argument)*;
a1=argument (',' an+=argument)* -> ^(ARGS[$a1.start.Token,"ARGS"] $a1 $an*);
// 4.0
argument:
argument_name argument_value
@ -278,7 +286,7 @@ dim_separators
delegate_creation_expression:
// 'new'
type_name '(' type_name ')' ;
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:
// 'new'
anonymous_object_initializer ;
@ -337,8 +345,8 @@ anonymous_function_parameter_modifier:
object_creation_expression:
// 'new'
type
( '(' argument_list? ')' object_or_collection_initializer?
| object_or_collection_initializer )
( '(' 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))
;
object_or_collection_initializer:
'{' (object_initializer
@ -400,7 +408,7 @@ commas:
type_name returns [string thetext]:
namespace_or_type_name { $thetext = $namespace_or_type_name.thetext; };
namespace_or_type_name returns [string thetext]:
t1=type_or_generic { $thetext=t1.type+formatTyargs($t1.generic_arguments); } ('::' tc=type_or_generic { $thetext+="::"+tc.type+formatTyargs($tc.generic_arguments); })? ('.' tn=type_or_generic { $thetext+="."+tn.type+formatTyargs($tn.generic_arguments); } )* ;
t1=type_or_generic { $thetext=t1.type+formatTyargs($t1.generic_arguments); } ('::'^ tc=type_or_generic { $thetext+="::"+tc.type+formatTyargs($tc.generic_arguments); })? ('.'^ tn=type_or_generic { $thetext+="."+tn.type+formatTyargs($tn.generic_arguments); } )* ;
type_or_generic returns [string type, List<string> generic_arguments]
@init {
$generic_arguments = new List<String>();
@ -413,7 +421,7 @@ type_or_generic returns [string type, List<string> generic_arguments]
// keving: as far as I can see this is (<interfacename>.)?identifier (<tyargs>)? at lease for C# 3.0 and less.
qid returns [string name, List<String> tyargs]: // qualified_identifier v2
qid_start qid_part* { $name=$qid_start.name; $tyargs = $qid_start.tyargs; }
(qs=qid_start -> $qs) (qp=qid_part[$qid.tree] -> $qp)* { $name=$qid_start.name; $tyargs = $qid_start.tyargs; }
;
qid_start returns [string name, List<String> tyargs]:
predefined_type { $name = $predefined_type.thetext; }
@ -425,8 +433,8 @@ qid_start returns [string name, List<String> tyargs]:
; // 0.ToString() is legal
qid_part:
access_identifier[ (CommonTree)adaptor.Create(KGHOLE, "KGHOLE") ] ;
qid_part[CommonTree lhs]:
access_identifier[ $lhs ] ;
generic_argument_list returns [List<string> tyargs]
@after {
@ -657,11 +665,11 @@ attribute_arguments:
) ')'
) ;
positional_argument_list:
positional_argument (',' positional_argument)* ;
a1=positional_argument (',' an+=positional_argument)* -> ^(ARGS[$a1.start.Token,"ARGS"] $a1 $an*);
positional_argument:
attribute_argument_expression ;
named_argument_list:
named_argument (',' named_argument)* ;
a1=named_argument (',' an+=named_argument)* -> ^(ARGS[$a1.start.Token,"ARGS"] $a1 $an*);
named_argument:
identifier '=' attribute_argument_expression ;
attribute_argument_expression:

View File

@ -102,6 +102,7 @@ class_member_declaration:
| ^(OPERATOR attributes? modifiers? type operator_declaration)
| ^(ENUM attributes? modifiers? enum_declaration[$modifiers.st])
| ^(DELEGATE attributes? modifiers? delegate_declaration)
| ^(CONVERSION_OPERATOR attributes? modifiers? conversion_operator_declaration)
| ^(CONSTRUCTOR attributes? modifiers? constructor_declaration)
| ^(DESTRUCTOR attributes? modifiers? destructor_declaration)
;
@ -146,11 +147,11 @@ primary_expression:
// ('this' brackets) => 'this' brackets primary_expression_part*
// | ('base' brackets) => 'this' brackets primary_expression_part*
// | primary_expression_start primary_expression_part*
| 'new' ( (object_creation_expression ('.'|'->'|'[')) =>
object_creation_expression primary_expression_part+ // new Foo(arg, arg).Member
| ^(NEW type argument_list? object_or_collection_initializer?)
| 'new' (
// try the simple one first, this has no argS and no expressions
// symantically could be object creation
| (delegate_creation_expression) => delegate_creation_expression// new FooDelegate (MyFunction)
(delegate_creation_expression) => delegate_creation_expression// new FooDelegate (MyFunction)
| object_creation_expression
| anonymous_object_creation_expression) // new {int X, string Y}
| sizeof_expression // sizeof (struct)
@ -206,7 +207,7 @@ paren_expression:
arguments:
'(' argument_list? ')' ;
argument_list:
argument (',' argument)*;
^(ARGS argument+);
// 4.0
argument:
argument_name argument_value
@ -355,14 +356,18 @@ commas:
type_name:
namespace_or_type_name -> { $namespace_or_type_name.st };
namespace_or_type_name:
t1=type_or_generic -> { $t1.st }
| ^('::' n2=namespace_or_type_name t2=type_or_generic) -> template(ns={ $n2.st }, tg={ $t2.st }) "<ns>::<tg>"
| ^('.' n3=namespace_or_type_name t3=type_or_generic) -> template(ns={ $n3.st }, tg={ $t3.st }) "<ns>.<tg>";
t1=type_or_generic ('::' t2=type_or_generic)? ('.' ts+=type_or_generic)* -> namespace_or_type(type1={$t1.st}, type2={$t2.st}, types={$ts});
// t1=type_or_generic ('::' t2=type_or_generic)? ('.' ts+=type_or_generic)* -> namespace_or_type(type1={$t1.st}, type2={$t2.st}, types={$ts});
type_or_generic:
(identifier generic_argument_list) => gi=identifier generic_argument_list -> template(name={ $gi.st }, args={ $generic_argument_list.st }) "<name><args>"
| i=identifier -> { $i.st };
qid: // qualified_identifier v2
qid_start qid_part*
^(access_operator qd=qid type_or_generic) -> template(op={ $access_operator.st }, start = { $qd.st}, end = { $type_or_generic.st }) "<start><op><end>"
| qid_start -> { $qid_start.st }
;
qid_start:
predefined_type
@ -589,11 +594,11 @@ attribute_arguments:
) ')'
) ;
positional_argument_list:
positional_argument (',' positional_argument)* ;
^(ARGS positional_argument+) ;
positional_argument:
attribute_argument_expression ;
named_argument_list:
named_argument (',' named_argument)* ;
^(ARGS named_argument+) ;
named_argument:
identifier '=' attribute_argument_expression ;
attribute_argument_expression:

View File

@ -47,6 +47,7 @@ class_member_declaration:
| ^(OPERATOR attributes? modifiers? type operator_declaration)
| ^(ENUM attributes? modifiers? enum_declaration)
| ^(DELEGATE attributes? modifiers? delegate_declaration)
| ^(CONVERSION_OPERATOR attributes? modifiers? conversion_operator_declaration)
| ^(CONSTRUCTOR attributes? modifiers? constructor_declaration)
| ^(DESTRUCTOR attributes? modifiers? destructor_declaration)
;
@ -90,11 +91,11 @@ primary_expression:
// ('this' brackets) => 'this' brackets primary_expression_part*
// | ('base' brackets) => 'this' brackets primary_expression_part*
// | primary_expression_start primary_expression_part*
| 'new' ( (object_creation_expression ('.'|'->'|'[')) =>
object_creation_expression primary_expression_part+ // new Foo(arg, arg).Member
| ^(NEW type argument_list? object_or_collection_initializer?)
| 'new' (
// try the simple one first, this has no argS and no expressions
// symantically could be object creation
| (delegate_creation_expression) => delegate_creation_expression// new FooDelegate (MyFunction)
(delegate_creation_expression) => delegate_creation_expression// new FooDelegate (MyFunction)
| object_creation_expression
| anonymous_object_creation_expression) // new {int X, string Y}
| sizeof_expression // sizeof (struct)
@ -133,7 +134,7 @@ paren_expression:
arguments:
'(' argument_list? ')' ;
argument_list:
argument (',' argument)*;
^(ARGS argument+);
// 4.0
argument:
argument_name argument_value
@ -282,13 +283,16 @@ commas:
type_name:
namespace_or_type_name ;
namespace_or_type_name:
type_or_generic ('::' type_or_generic)? ('.' type_or_generic)* ;
type_or_generic
| ^('::' namespace_or_type_name type_or_generic)
| ^('.' namespace_or_type_name type_or_generic) ;
type_or_generic:
(identifier generic_argument_list) => identifier generic_argument_list
| identifier ;
qid: // qualified_identifier v2
qid_start qid_part*
^(access_operator qid type_or_generic)
| qid_start
;
qid_start:
predefined_type
@ -534,11 +538,11 @@ attribute_arguments:
) ')'
) ;
positional_argument_list:
positional_argument (',' positional_argument)* ;
^(ARGS positional_argument+) ;
positional_argument:
attribute_argument_expression ;
named_argument_list:
named_argument (',' named_argument)* ;
^(ARGS named_argument+) ;
named_argument:
identifier '=' attribute_argument_expression ;
attribute_argument_expression:

View File

@ -41,6 +41,8 @@ tokens {
TEMPPARENS;
INDEX;
APPLY;
ARGS;
NEW;
OPEN_BRACKET='[';
CLOSE_BRACKET=']';