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

Set Tokens property on CommonTreeStream produced from parse_file.

Otherwise 'text' attribute doesn't work.  Took me ages to find that too.
Some simplification of code
This commit is contained in:
Kevin Glynn 2010-10-28 11:43:04 +02:00
parent b62e86c401
commit e060727f03
3 changed files with 11 additions and 15 deletions

View File

@ -1,5 +1,5 @@
using System; using System;
namespace cs2jTest.Various.Features namespace cs2jTest.Various.Features.join.yield
{ {
// delegate declaration // delegate declaration

View File

@ -190,22 +190,18 @@ namespace RusticiSoftware.Translator.CSharp
public static CommonTreeNodeStream parseFile(string fullName) public static CommonTreeNodeStream parseFile(string fullName)
{ {
CommonTokenStream tokens = null;
if (cfg.Verbosity > 2) Console.WriteLine("Parsing " + Path.GetFileName(fullName)); if (cfg.Verbosity > 2) Console.WriteLine("Parsing " + Path.GetFileName(fullName));
PreProcessor lex = new PreProcessor();;
lex.AddDefine(cfg.MacroDefines);
ICharStream input = new ANTLRFileStream(fullName); ICharStream input = new ANTLRFileStream(fullName);
PreProcessor lex = new PreProcessor();;
lex.AddDefine(cfg.MacroDefines);
lex.CharStream = input; lex.CharStream = input;
tokens = new CommonTokenStream(lex); CommonTokenStream tokens = new CommonTokenStream(lex);
csParser p = new csParser(tokens); csParser p = new csParser(tokens);
csParser.compilation_unit_return parser_rt; csParser.compilation_unit_return parser_rt = p.compilation_unit();
parser_rt = p.compilation_unit();
if (parser_rt == null || parser_rt.Tree == null) if (parser_rt == null || parser_rt.Tree == null)
{ {
@ -220,12 +216,12 @@ namespace RusticiSoftware.Translator.CSharp
} }
CommonTreeNodeStream nodes = new CommonTreeNodeStream(parser_rt.Tree); CommonTreeNodeStream nodes = new CommonTreeNodeStream(parser_rt.Tree);
nodes.TokenStream = tokens;
return nodes; return nodes;
} }
// Here's where we do the real work...
// Here's where we do the real work...
public static void addNetTranslation(string fullName) public static void addNetTranslation(string fullName)
{ {
Stream s = new FileStream(fullName, FileMode.Open, FileAccess.Read); Stream s = new FileStream(fullName, FileMode.Open, FileAccess.Read);

View File

@ -39,7 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Commandlineparameters>-dumpcsharp /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/cs2jTest/TestDLLs/Various.cs</Commandlineparameters> <Commandlineparameters>-v -v -v -dumpcsharp -debug 10 /Users/keving/gitrepos/cs2j/CSharpTranslator/antlr3/cs2jTest/TestDLLs/Various.cs</Commandlineparameters>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>