mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Use common code in AntlrUtils
This commit is contained in:
parent
85bce1eac3
commit
416c6fd003
@ -9,6 +9,7 @@ using Antlr.Runtime;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using RusticiSoftware.Translator.Utils;
|
||||
using RusticiSoftware.Translator.AntlrUtils;
|
||||
using RusticiSoftware.Translator.CLR;
|
||||
|
||||
namespace RusticiSoftware.Translator.CSharp
|
||||
@ -340,54 +341,13 @@ namespace RusticiSoftware.Translator.CSharp
|
||||
// Dump the tree nodes if -dumpcsharp is passed on the command line.
|
||||
if (dumpCSharp)
|
||||
{
|
||||
DumpNodes(nodes);
|
||||
AntlrUtils.AntlrUtils.DumpNodes(nodes);
|
||||
}
|
||||
|
||||
return nodes;
|
||||
|
||||
}
|
||||
|
||||
/// <summary> DumpNodes
|
||||
/// The CommonTreeNodeStream has a tree in "flat form". The UP and DOWN tokens represent the branches of the
|
||||
/// tree. Dump these out in tree form to the console.
|
||||
/// </summary>
|
||||
private static void DumpNodes(CommonTreeNodeStream nodes)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine("Nodes");
|
||||
int spaces = 0;
|
||||
string str_spaces = " ";
|
||||
object o_prev = string.Empty;
|
||||
//for (int n = 0; n < nodes.Count; ++n)
|
||||
object o = nodes.NextElement();
|
||||
while (!nodes.IsEndOfFile(o))
|
||||
{
|
||||
//object o = nodes.Get(n);
|
||||
//object o = nodes[n];
|
||||
|
||||
if (o.ToString() == "DOWN")
|
||||
{
|
||||
spaces += 2;
|
||||
if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
||||
Console.Write("\r\n{0} {1}", str_spaces.Substring(0, spaces), o_prev);
|
||||
}
|
||||
else if (o.ToString() == "UP")
|
||||
{
|
||||
spaces -= 2;
|
||||
if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
||||
Console.Write(" {0}\r\n{1}", o_prev, str_spaces.Substring(0, spaces));
|
||||
}
|
||||
else if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
||||
Console.Write(" {0}", o_prev.ToString());
|
||||
|
||||
o_prev = o;
|
||||
o = nodes.NextElement();
|
||||
}
|
||||
if (o_prev.ToString() != "UP" && o_prev.ToString() != "DOWN")
|
||||
Console.WriteLine(" {0}", o_prev.ToString());
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
// Here's where we do the real work...
|
||||
public static void addNetTranslation(string fullName, Stream s)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user