diff --git a/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g b/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g index c9a6f59..759f61a 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g +++ b/CSharpTranslator/antlr3/src/cs2j/CSharp/NetMaker.g @@ -75,8 +75,8 @@ scope NSContext { if (ret == null && AppEnv.ContainsKey(name)) { ret = AppEnv[name]; } - if (ret != null) - Console.Out.WriteLine("findType: found {0}", ret.TypeName); +// if (ret != null) +// Console.Out.WriteLine("findType: found {0}", ret.TypeName); return ret; } @@ -337,8 +337,8 @@ namespace_or_type_name returns [String name, List tyargs]: | ^('::' namespace_or_type_name type_or_generic) { $name = "System.Object"; } // give up, we don't support these | ^(d='.' n1=namespace_or_type_name type_or_generic) { WarningAssert($n1.tyargs == null, $d.token.Line, "Didn't expect type arguments in prefix of type name"); $name = $n1.name + "." + $type_or_generic.name; $tyargs = $type_or_generic.tyargs; } ; type_or_generic returns [String name, List tyargs]: - (identifier generic_argument_list) => identifier { $name = $identifier.text; } generic_argument_list { $tyargs = $generic_argument_list.argTexts; } - | identifier { $name = $identifier.text; }; + (identifier generic_argument_list) => identifier { $name = $identifier.thetext; } generic_argument_list { $tyargs = $generic_argument_list.argTexts; } + | identifier { $name = $identifier.thetext; }; qid: // qualified_identifier v2 ^(access_operator qid type_or_generic) @@ -619,7 +619,7 @@ scope NSContext; $NSContext::namespaces = new List(); } : - ^(CLASS identifier { $NSContext::currentNS = ParentNameSpace + "." + $identifier.text; } type_parameter_constraints_clauses? type_parameter_list? + ^(CLASS identifier { $NSContext::currentNS = ParentNameSpace + "." + $identifier.thetext; } type_parameter_constraints_clauses? type_parameter_list? class_implements? { $NSContext::aliases.Add($NSContext::currentNS); @@ -995,8 +995,10 @@ predefined_type returns [TypeRepTemplate dotNetType] | 'ushort' { ns = "System.UInt16"; } ; -identifier: - IDENTIFIER | also_keyword; +// Don't trust identifier.text in tree grammars: Doesn't work for our magic additions because the text function goes back to the +// original token stream to make up the text for a tree node +identifier returns [String thetext]: + IDENTIFIER { $thetext = $IDENTIFIER.text; } | also_keyword { $thetext = $also_keyword.text; }; // might need to return text from also_keyword too if we start manufacturing those keyword: 'abstract' | 'as' | 'base' | 'bool' | 'break' | 'byte' | 'case' | 'catch' | 'char' | 'checked' | 'class' | 'const' | 'continue' | 'decimal' | 'default' | 'delegate' | 'do' | 'double' | 'else' | 'enum' | 'event' | 'explicit' | 'extern' | 'false' | 'finally' | 'fixed' | 'float' | 'for' | 'foreach' | 'goto' | 'if' | 'implicit' | 'in' | 'int' | 'interface' | 'internal' | 'is' | 'lock' | 'long' | 'namespace' | 'new' | 'null' | 'object' | 'operator' | 'out' | 'override' | 'params' | 'private' | 'protected' | 'public' | 'readonly' | 'ref' | 'return' | 'sbyte' | 'sealed' | 'short' | 'sizeof' | 'stackalloc' | 'static' | 'string' | 'struct' | 'switch' | 'this' | 'throw' | 'true' | 'try' | 'typeof' | 'uint' | 'ulong' | 'unchecked' | 'unsafe' | 'ushort' | 'using' | 'virtual' | 'void' | 'volatile' ; diff --git a/CSharpTranslator/antlr3/src/cs2j/CSharp/TemplateExtracter.g b/CSharpTranslator/antlr3/src/cs2j/CSharp/TemplateExtracter.g index 72ded17..6d34cdb 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CSharp/TemplateExtracter.g +++ b/CSharpTranslator/antlr3/src/cs2j/CSharp/TemplateExtracter.g @@ -95,7 +95,7 @@ scope NSContext; { Debug("namespace: " + $qi.thetext); $NSContext::nss.Add(new UseRepTemplate($qi.thetext)); // extend parent namespace - $NSContext::currentNS = this.ParentNameSpace + $qi.thetext; + $NSContext::currentNS = ParentNameSpace + (String.IsNullOrEmpty(ParentNameSpace) ? "" : ".") + $qi.thetext; } namespace_block ';'? ; namespace_block: @@ -112,11 +112,11 @@ using_directive: (using_alias_directive | using_namespace_directive) ; using_alias_directive -@after{ $NSContext::nss.Add(new UseRepTemplate($i.text, $ns.text));} +@after{ $NSContext::nss.Add(new UseRepTemplate($i.thetext, $ns.thetext));} : 'using' i=identifier '=' ns=namespace_or_type_name ';' ; using_namespace_directive -@after{ $NSContext::nss.Add(new UseRepTemplate($ns.text));} +@after{ $NSContext::nss.Add(new UseRepTemplate($ns.thetext)); } : 'using' ns=namespace_name ';' ; namespace_member_declarations: @@ -136,8 +136,8 @@ type_declaration: // Identifiers qualified_identifier returns [string thetext]: i1=identifier { $thetext = $i1.text; } ('.' ip=identifier { $thetext += "." + $ip.text; } )*; -namespace_name - : namespace_or_type_name ; +namespace_name returns [string thetext] + : namespace_or_type_name { $thetext = $namespace_or_type_name.thetext; }; modifiers: modifier+ ; @@ -1319,8 +1319,8 @@ predefined_type returns [string thetext]: | 'ushort' { $thetext = "System.UInt16"; } ; -identifier: - IDENTIFIER | also_keyword; +identifier returns [string thetext]: + IDENTIFIER { $thetext = $IDENTIFIER.text; } | also_keyword { $thetext = $also_keyword.text; }; keyword: 'abstract' | 'as' | 'base' | 'bool' | 'break' | 'byte' | 'case' | 'catch' | 'char' | 'checked' | 'class' | 'const' | 'continue' | 'decimal' | 'default' | 'delegate' | 'do' | 'double' | 'else' | 'enum' | 'event' | 'explicit' | 'extern' | 'false' | 'finally' | 'fixed' | 'float' | 'for' | 'foreach' | 'goto' | 'if' | 'implicit' | 'in' | 'int' | 'interface' | 'internal' | 'is' | 'lock' | 'long' | 'namespace' | 'new' | 'null' | 'object' | 'operator' | 'out' | 'override' | 'params' | 'private' | 'protected' | 'public' | 'readonly' | 'ref' | 'return' | 'sbyte' | 'sealed' | 'short' | 'sizeof' | 'stackalloc' | 'static' | 'string' | 'struct' | 'switch' | 'this' | 'throw' | 'true' | 'try' | 'typeof' | 'uint' | 'ulong' | 'unchecked' | 'unsafe' | 'ushort' | 'using' | 'virtual' | 'void' | 'volatile' ; diff --git a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj index 86e6dcf..eb2644c 100644 --- a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj +++ b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj @@ -39,7 +39,7 @@ DEBUG;TRACE prompt 4 - -translator-timestamp-files=false -translator-keep-parens=false -netdir=/Users/keving/gitrepos/cs2j/CS2JLibrary/NetFramework/ -dumpxmls -xmldir=/Users/keving/tmp/xml/se -odir=/Users/keving/tmp/java/se/src /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/Logic/Integration/ExternalConfiguration.cs + -translator-timestamp-files=false -translator-keep-parens=false -netdir=/Users/keving/gitrepos/cs2j/CS2JLibrary/NetFramework/ -dumpxmls -xmldir=/Users/keving/tmp/xml/se -odir=/Users/keving/tmp/java/se/src -appdir=/Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/Logic/Integration/DefaultIntegration.cs pdbonly