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

use 'thetext' attributes to be sure we are getting the necessary

This commit is contained in:
Kevin Glynn 2011-01-07 19:36:55 +01:00
parent 5e8707c7b9
commit 6b5201b9f3
3 changed files with 17 additions and 15 deletions

View File

@ -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<string> 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<String> 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<string>();
}
:
^(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' ;

View File

@ -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' ;

View File

@ -39,7 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Commandlineparameters> -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</Commandlineparameters>
<Commandlineparameters>-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</Commandlineparameters>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>