mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
simplify setup and print ast nodes
This commit is contained in:
parent
542817993a
commit
379450ebf2
@ -4,9 +4,12 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
using Path = System.IO.Path;
|
using Path = System.IO.Path;
|
||||||
using Antlr.Runtime;
|
using Antlr.Runtime;
|
||||||
using RusticiSoftware.Translator.CSharp;
|
using RusticiSoftware.Translator.CSharp;
|
||||||
|
using System.IO;
|
||||||
|
using Antlr.Runtime.Tree;
|
||||||
|
|
||||||
public class MinDriver
|
public class MinDriver
|
||||||
{
|
{
|
||||||
|
|
||||||
public static void MinDriverMain(string[] args)
|
public static void MinDriverMain(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length > 0)
|
if (args.Length > 0)
|
||||||
@ -16,12 +19,28 @@ namespace RusticiSoftware.Translator.CSharp
|
|||||||
{
|
{
|
||||||
inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
|
inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
|
||||||
}
|
}
|
||||||
ICharStream input = new ANTLRFileStream(inputFileName);
|
if (!File.Exists(inputFileName))
|
||||||
PreProcessor lex = new PreProcessor(input);
|
{
|
||||||
ITokenStream tokens = new TokenRewriteStream(lex);
|
Console.Error.WriteLine("Error: Can't find file " + inputFileName);
|
||||||
csParser parser = new csParser(tokens);
|
}
|
||||||
parser.compilation_unit();
|
else
|
||||||
Console.Out.WriteLine(tokens);
|
{
|
||||||
|
CommonTokenStream tokens = null;
|
||||||
|
|
||||||
|
Console.WriteLine("Parsing " + Path.GetFileName(inputFileName));
|
||||||
|
PreProcessor lex = new PreProcessor();;
|
||||||
|
|
||||||
|
ICharStream input = new ANTLRFileStream(inputFileName);
|
||||||
|
lex.CharStream = input;
|
||||||
|
|
||||||
|
tokens = new CommonTokenStream(lex);
|
||||||
|
csParser p = new csParser(tokens);
|
||||||
|
csParser.compilation_unit_return parser_rt;
|
||||||
|
|
||||||
|
parser_rt = p.compilation_unit();
|
||||||
|
|
||||||
|
Console.Out.WriteLine(((ITree)parser_rt.Tree).ToStringTree());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console.Error.WriteLine("Usage: minDriver <input-file>");
|
Console.Error.WriteLine("Usage: minDriver <input-file>");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user