From 18844471202f98c082f1390cb1b98095da0c16a0 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Wed, 24 Nov 2010 07:52:54 +0100 Subject: [PATCH] checkpoint --- CSharpTranslator/antlr3/CSharpTranslator.sln | 32 +++--- CSharpTranslator/antlr3/mkit | 2 +- .../antlr3/src/cs2j/CSharp/JavaMaker.g | 38 ++++--- .../antlr3/src/cs2j/CSharp/JavaPrettyPrint.g | 58 ++++------ .../antlr3/src/cs2j/CSharp/NetMaker.g | 102 +++++++++++------- CSharpTranslator/antlr3/src/cs2j/cs2j.csproj | 2 +- 6 files changed, 124 insertions(+), 110 deletions(-) diff --git a/CSharpTranslator/antlr3/CSharpTranslator.sln b/CSharpTranslator/antlr3/CSharpTranslator.sln index f00eaf5..ff07b40 100644 --- a/CSharpTranslator/antlr3/CSharpTranslator.sln +++ b/CSharpTranslator/antlr3/CSharpTranslator.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +# Visual C# Express 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2j", "src\cs2j\cs2j.csproj", "{CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Antlr3.Runtime", "src\Antlr.Runtime\Antlr3.Runtime.csproj", "{CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}" @@ -11,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build.xml = build.xml EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2jTest", "cs2jTest\cs2jTest.csproj", "{28A229C9-2F22-4384-B224-61A5C67638CE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDesk.Options", "src\NDesk.Options\NDesk.Options.csproj", "{E6ACBB37-AF38-45E1-B399-0CEE63809A15}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs2jTemplateGen", "src\cs2jTemplateGen\cs2jTemplateGen.csproj", "{CC80B16E-0700-4AA5-ABA0-ADBCD9316952}" @@ -20,28 +18,18 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU Default|Any CPU = Default|Any CPU + Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {28A229C9-2F22-4384-B224-61A5C67638CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28A229C9-2F22-4384-B224-61A5C67638CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28A229C9-2F22-4384-B224-61A5C67638CE}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {28A229C9-2F22-4384-B224-61A5C67638CE}.Default|Any CPU.Build.0 = Debug|Any CPU - {28A229C9-2F22-4384-B224-61A5C67638CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {28A229C9-2F22-4384-B224-61A5C67638CE}.Release|Any CPU.Build.0 = Release|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.ActiveCfg = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.Build.0 = Debug|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.Build.0 = Release|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Default|Any CPU.ActiveCfg = Debug|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE961AC5-C8D4-41B3-AAF3-23FA8FAEE8AD}.Release|Any CPU.Build.0 = Release|Any CPU {CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Default|Any CPU.ActiveCfg = Debug|Any CPU {CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF15D0D5-BE72-4F98-B70F-229ABA1DF0E8}.Release|Any CPU.Build.0 = Release|Any CPU {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -50,13 +38,19 @@ Global {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Default|Any CPU.Build.0 = Debug|Any CPU {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6ACBB37-AF38-45E1-B399-0CEE63809A15}.Release|Any CPU.Build.0 = Release|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.ActiveCfg = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Default|Any CPU.Build.0 = Debug|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC80B16E-0700-4AA5-ABA0-ADBCD9316952}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = src\cs2j\cs2j.csproj EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection EndGlobal diff --git a/CSharpTranslator/antlr3/mkit b/CSharpTranslator/antlr3/mkit index e3990c2..208e1e7 100755 --- a/CSharpTranslator/antlr3/mkit +++ b/CSharpTranslator/antlr3/mkit @@ -14,6 +14,6 @@ java -Xmx512m -jar ../../../jar/antlr-3.3.jar -Xconversiontimeout 5000 -make -ve # echo JavaPrettyPrint.g java -Xmx512m -jar ../../../jar/antlr-3.3.jar -Xconversiontimeout 10000 -make -verbose JavaPrettyPrint.g cd ../../../ -xbuild +#xbuild echo 'All Done' diff --git a/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaMaker.g b/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaMaker.g index 4a6e9d1..032db1c 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaMaker.g +++ b/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaMaker.g @@ -497,7 +497,8 @@ unary_expression: | addressof_expression ; cast_expression: - '(' type ')' unary_expression ; + //'(' type ')' unary_expression ; + '(' type ')' unary_expression -> ^(CAST_EXPR type SEP unary_expression); assignment_operator: '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>' '>=' ; pre_increment_expression: @@ -521,35 +522,42 @@ non_assignment_expression: /////////////////////////////////////////////////////// multiplicative_expression: - unary_expression ( ('*'|'/'|'%') unary_expression)* ; + (u1=unary_expression -> $u1) ((op='*'|op='/'|op='%') un=unary_expression -> ^($op $multiplicative_expression $un) )* ; additive_expression: - multiplicative_expression (('+'|'-') multiplicative_expression)* ; + multiplicative_expression (('+'|'-')^ multiplicative_expression)* ; // >> check needed (no whitespace) shift_expression: - additive_expression (('<<'|'>' '>') additive_expression)* ; + a1=additive_expression ((so='<<' a3=additive_expression -> ^($so $a1 $a3)) + | ('>' '>' a2=additive_expression -> ^(RIGHT_SHIFT $a1 $a2)) + )* ; relational_expression: - shift_expression - ( (('<'|'>'|'>='|'<=') shift_expression) - | (('is'|'as') non_nullable_type) + (s1=shift_expression -> $s1) + ( ((o='<'|o='>'|o='>='|o='<=') s2=shift_expression -> ^($o $relational_expression $s2)) + | (i='is' t=non_nullable_type -> ^(INSTANCEOF[$i.Token,"instanceof"] $relational_expression $t) + | i1='as' t1=non_nullable_type -> ^(COND_EXPR[$i1.Token, "?:"] + ^(INSTANCEOF[$i1.Token,"instanceof"] { (CommonTree)adaptor.DupTree($relational_expression.tree) } { (CommonTree)adaptor.DupTree($t1.tree) } ) + ^(CAST_EXPR[$i1.Token, "(cast)"] { (CommonTree)adaptor.DupTree($t1.tree) } SEP[$i1.Token, "SEP"] { (CommonTree)adaptor.DupTree($relational_expression.tree) }) + ^(CAST_EXPR[$i1.Token, "(cast)"] { (CommonTree)adaptor.DupTree($t1.tree) } SEP[$i1.Token, "SEP"] NULL[$i1.Token, "null"]))) )* ; equality_expression: relational_expression - (('=='|'!=') relational_expression)* ; + (('=='|'!=')^ relational_expression)* ; and_expression: - equality_expression ('&' equality_expression)* ; + equality_expression ('&'^ equality_expression)* ; exclusive_or_expression: - and_expression ('^' and_expression)* ; + and_expression ('^'^ and_expression)* ; inclusive_or_expression: - exclusive_or_expression ('|' exclusive_or_expression)* ; + exclusive_or_expression ('|'^ exclusive_or_expression)* ; conditional_and_expression: - inclusive_or_expression ('&&' inclusive_or_expression)* ; + inclusive_or_expression ('&&'^ inclusive_or_expression)* ; conditional_or_expression: - conditional_and_expression ('||' conditional_and_expression)* ; + conditional_and_expression ('||'^ conditional_and_expression)* ; null_coalescing_expression: - conditional_or_expression ('??' conditional_or_expression)* ; + conditional_or_expression ('??'^ conditional_or_expression)* ; conditional_expression: - null_coalescing_expression ('?' expression ':' expression)? ; + (null_coalescing_expression '?' expression ':') => e1=null_coalescing_expression q='?' e2=expression ':' e3=expression -> ^(COND_EXPR[$q.Token, "?:"] $e1 $e2 $e3) + | null_coalescing_expression ; /////////////////////////////////////////////////////// // lambda Section diff --git a/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaPrettyPrint.g b/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaPrettyPrint.g index 7e8d4d6..2d5f354 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaPrettyPrint.g +++ b/CSharpTranslator/antlr3/src/cs2j/CSharp/JavaPrettyPrint.g @@ -426,44 +426,30 @@ non_assignment_expression: //'non ASSIGNment' (anonymous_function_signature '=>') => lambda_expression | (query_expression) => query_expression - | conditional_expression + | ^(COND_EXPR non_assignment_expression non_assignment_expression non_assignment_expression) + | ^('??' non_assignment_expression non_assignment_expression) + | ^('||' non_assignment_expression non_assignment_expression) + | ^('&&' non_assignment_expression non_assignment_expression) + | ^('|' non_assignment_expression non_assignment_expression) + | ^('^' non_assignment_expression non_assignment_expression) + | ^('&' non_assignment_expression non_assignment_expression) + | ^('==' non_assignment_expression non_assignment_expression) + | ^('!=' non_assignment_expression non_assignment_expression) + | ^('>' non_assignment_expression non_assignment_expression) + | ^('<' non_assignment_expression non_assignment_expression) + | ^('>=' non_assignment_expression non_assignment_expression) + | ^('<=' non_assignment_expression non_assignment_expression) + | ^(INSTANCEOF non_assignment_expression non_nullable_type) + | ^('<<' non_assignment_expression non_assignment_expression) + | ^('>>' non_assignment_expression non_assignment_expression) + | ^('+' non_assignment_expression non_assignment_expression) + | ^('-' non_assignment_expression non_assignment_expression) + | ^('*' non_assignment_expression non_assignment_expression) + | ^('/' non_assignment_expression non_assignment_expression) + | ^('%' non_assignment_expression non_assignment_expression) + | ^(UNARY_EXPR unary_expression) -> { $unary_expression.st } ; -/////////////////////////////////////////////////////// -// Conditional Expression Section -/////////////////////////////////////////////////////// - -multiplicative_expression: - unary_expression ( ('*'|'/'|'%') unary_expression)* ; -additive_expression: - multiplicative_expression (('+'|'-') multiplicative_expression)* ; -// >> check needed (no whitespace) -shift_expression: - additive_expression (('<<'|'>' '>') additive_expression)* ; -relational_expression: - shift_expression - ( (('<'|'>'|'>='|'<=') shift_expression) - | (('is'|'as') non_nullable_type) - )* ; -equality_expression: - relational_expression - (('=='|'!=') relational_expression)* ; -and_expression: - equality_expression ('&' equality_expression)* ; -exclusive_or_expression: - and_expression ('^' and_expression)* ; -inclusive_or_expression: - exclusive_or_expression ('|' exclusive_or_expression)* ; -conditional_and_expression: - inclusive_or_expression ('&&' inclusive_or_expression)* ; -conditional_or_expression: - conditional_and_expression ('||' conditional_and_expression)* ; - -null_coalescing_expression: - conditional_or_expression ('??' conditional_or_expression)* ; -conditional_expression: - null_coalescing_expression ('?' expression ':' expression)? ; - /////////////////////////////////////////////////////// // lambda Section /////////////////////////////////////////////////////// diff --git a/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g b/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g index 4ff4b42..47eef45 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g +++ b/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g @@ -335,8 +335,10 @@ expression_list: assignment: unary_expression assignment_operator expression ; unary_expression: - //('(' arguments ')' ('[' | '.' | '(')) => primary_or_array_creation_expression - (cast_expression) => cast_expression + //('(' arguments ')' ('[' | '.' | '(')) => primary_or_array_creation_expression + + //(cast_expression) => cast_expression + ^(CAST_EXPR type SEP unary_expression) | primary_or_array_creation_expression | '+' unary_expression | '-' unary_expression @@ -348,7 +350,7 @@ unary_expression: | addressof_expression ; cast_expression: - '(' type ')' unary_expression ; + '(' type ')' non_assignment_expression ; assignment_operator: '=' | '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>' '>=' ; pre_increment_expression: @@ -360,48 +362,72 @@ pointer_indirection_expression: addressof_expression: '&' unary_expression ; + non_assignment_expression: //'non ASSIGNment' (anonymous_function_signature '=>') => lambda_expression | (query_expression) => query_expression - | conditional_expression + | ^(COND_EXPR non_assignment_expression expression expression) + | ^('??' non_assignment_expression non_assignment_expression) + | ^('||' non_assignment_expression non_assignment_expression) + | ^('&&' non_assignment_expression non_assignment_expression) + | ^('|' non_assignment_expression non_assignment_expression) + | ^('^' non_assignment_expression non_assignment_expression) + | ^('&' non_assignment_expression non_assignment_expression) + | ^('==' non_assignment_expression non_assignment_expression) + | ^('!=' non_assignment_expression non_assignment_expression) + | ^('>' non_assignment_expression non_assignment_expression) + | ^('<' non_assignment_expression non_assignment_expression) + | ^('>=' non_assignment_expression non_assignment_expression) + | ^('<=' non_assignment_expression non_assignment_expression) + | ^(INSTANCEOF non_assignment_expression non_nullable_type) + | ^('<<' non_assignment_expression non_assignment_expression) + | ^('>>' non_assignment_expression non_assignment_expression) + | ^('+' non_assignment_expression non_assignment_expression) + | ^('-' non_assignment_expression non_assignment_expression) + | ^('*' non_assignment_expression non_assignment_expression) + | ^('/' non_assignment_expression non_assignment_expression) + | ^('%' non_assignment_expression non_assignment_expression) + // | ^(UNARY_EXPRESSION unary_expression) + | unary_expression ; -/////////////////////////////////////////////////////// -// Conditional Expression Section -/////////////////////////////////////////////////////// +// /////////////////////////////////////////////////////// +// // Conditional Expression Section +// /////////////////////////////////////////////////////// +// +// multiplicative_expression: +// unary_expression ( ('*'|'/'|'%') unary_expression)* ; +// additive_expression: +// multiplicative_expression (('+'|'-') multiplicative_expression)* ; +// // >> check needed (no whitespace) +// shift_expression: +// additive_expression (('<<'|'>' '>') additive_expression)* ; +// relational_expression: +// shift_expression +// ( (('<'|'>'|'>='|'<=') shift_expression) +// | (('is'|'as') non_nullable_type) +// )* ; +// equality_expression: +// relational_expression +// (('=='|'!=') relational_expression)* ; +// and_expression: +// equality_expression ('&' equality_expression)* ; +// exclusive_or_expression: +// and_expression ('^' and_expression)* ; +// inclusive_or_expression: +// exclusive_or_expression ('|' exclusive_or_expression)* ; +// conditional_and_expression: +// inclusive_or_expression ('&&' inclusive_or_expression)* ; +// conditional_or_expression: +// conditional_and_expression ('||' conditional_and_expression)* ; +// +// null_coalescing_expression: +// conditional_or_expression ('??' conditional_or_expression)* ; +// conditional_expression: +// null_coalescing_expression ('?' expression ':' expression)? ; +// -multiplicative_expression: - unary_expression ( ('*'|'/'|'%') unary_expression)* ; -additive_expression: - multiplicative_expression (('+'|'-') multiplicative_expression)* ; -// >> check needed (no whitespace) -shift_expression: - additive_expression (('<<'|'>' '>') additive_expression)* ; -relational_expression: - shift_expression - ( (('<'|'>'|'>='|'<=') shift_expression) - | (('is'|'as') non_nullable_type) - )* ; -equality_expression: - relational_expression - (('=='|'!=') relational_expression)* ; -and_expression: - equality_expression ('&' equality_expression)* ; -exclusive_or_expression: - and_expression ('^' and_expression)* ; -inclusive_or_expression: - exclusive_or_expression ('|' exclusive_or_expression)* ; -conditional_and_expression: - inclusive_or_expression ('&&' inclusive_or_expression)* ; -conditional_or_expression: - conditional_and_expression ('||' conditional_and_expression)* ; - -null_coalescing_expression: - conditional_or_expression ('??' conditional_or_expression)* ; -conditional_expression: - null_coalescing_expression ('?' expression ':' expression)? ; - /////////////////////////////////////////////////////// // lambda Section /////////////////////////////////////////////////////// diff --git a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj index 52a617b..842be22 100644 --- a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj +++ b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj @@ -39,7 +39,7 @@ DEBUG;TRACE prompt 4 - -warnings -debug 10 -dumpxmls -xmldir=/tmp/xml/se -odir=/tmp/java/se /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/DataHelp/IDataHelper.cs + -warnings -debug 10 -dumpxmls -xmldir=/tmp/xml/se -odir=/tmp/java/se /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/DataHelp/Db2OleDataHelper.cs pdbonly