From 3eea1c7aafa21422c949ecf9012dcefe2f990e50 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Thu, 15 Jul 2010 14:18:17 -0500 Subject: [PATCH] simplify #define processing --- CSharpTranslator/antlr3/src/cs2j/CLR/cs2j.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/CSharpTranslator/antlr3/src/cs2j/CLR/cs2j.cs b/CSharpTranslator/antlr3/src/cs2j/CLR/cs2j.cs index d683ba1..86717c6 100644 --- a/CSharpTranslator/antlr3/src/cs2j/CLR/cs2j.cs +++ b/CSharpTranslator/antlr3/src/cs2j/CLR/cs2j.cs @@ -40,7 +40,7 @@ namespace RusticiSoftware.Translator.CSharp internal static ArrayList exAppRoot = new ArrayList(); internal static ArrayList exclude = new ArrayList(); internal static DirectoryHT appEnv = new DirectoryHT(null); - internal static ArrayList macroDefines = new ArrayList(); + internal static List macroDefines = new List(); internal static XmlTextWriter enumXmlWriter; internal static string xmldumpDir = Path.Combine(".", "tmpXMLs"); internal static int verbosity = 0; @@ -300,19 +300,14 @@ namespace RusticiSoftware.Translator.CSharp Console.WriteLine("Parsing " + Path.GetFileName(fullName)); PreProcessor lex = new PreProcessor(); - foreach (string d in macroDefines) - { - lex.AddDefine(d); - } + lex.AddDefine(macroDefines); + ICharStream input = new ANTLRFileStream(fullName); lex.CharStream = input; tokens = new CommonTokenStream(lex); csParser p = new csParser(tokens); - object parser_rt; - CommonTree tree = null; - - parser_rt = p.compilation_unit(); + object parser_rt = p.compilation_unit(); // Sometimes ANTLR returns a CommonErrorNode if we can't parse the file if (parser_rt is CommonErrorNode) @@ -321,7 +316,7 @@ namespace RusticiSoftware.Translator.CSharp return null; } - tree = (CommonTree)((RuleReturnScope)parser_rt).Tree; + CommonTree tree = (CommonTree)((RuleReturnScope)parser_rt).Tree; // Check if we didn't get an AST // This often happens if your grammar and tree grammar don't match if (tree == null)