private void CompilePrepare() { if (File.Exists(mainIniFile)) { SinumerikLexer definitionLexer = new SinumerikLexer(CharStreams.fromPath(mainIniFile), null, _errorTextWriter); SinumerikParser definitionParser = new SinumerikParser(new CommonTokenStream(definitionLexer), null, _errorTextWriter); definitionParser.BuildParseTree = true; IParseTree definitionTree = definitionParser.parse(); GlobalVarsVisitor globalVars = new GlobalVarsVisitor(mainScope); globalVars.Visit(definitionTree); } foreach (var fileName in Directory.EnumerateFiles(subDir)) { SinumerikLexer subLexer = new SinumerikLexer(CharStreams.fromPath(fileName), null, _errorTextWriter); SinumerikParser subParser = new SinumerikParser(new CommonTokenStream(subLexer), null, _errorTextWriter); subParser.BuildParseTree = true; IParseTree subTree = subParser.parse(); SymbolVisitor subSymbolVisitor = new SymbolVisitor(functions); subSymbolVisitor.Visit(subTree); } mainLexer = new SinumerikLexer(CharStreams.fromstring(_text.Text), null, _errorTextWriter); }
public StringBuilder Compile() { Scope scope = new Scope(mainScope); SinumerikParser mainParser = new SinumerikParser(new CommonTokenStream(mainLexer), null, _errorTextWriter); mainParser.BuildParseTree = true; IParseTree mainTree = mainParser.parse(); // outputTextWriter.Close(); SymbolVisitor mainSymbolVisitor = new SymbolVisitor(functions); mainSymbolVisitor.Visit(mainTree); EvalVisitor visitor = new EvalVisitor(scope, functions, _gcodeOutput); visitor.Visit(mainTree); return(_gcodeOutput); }