public void Run() { try { ParserErrorHandler errorHandler = new ParserErrorHandler(OnParserError); foreach (ICompilerInput input in _context.CompilerParameters.Input) { try { using (System.IO.TextReader reader = input.Open()) { Module module = BooParser.ParseModule(input.Name, reader, errorHandler); if (null != module) { _context.CompileUnit.Modules.Add(module); } } } catch (Exception x) { _context.Errors.InputError(input, x); } } } finally { _context = null; } }
public static Module ParseModule(string readerName, TextReader reader, ParserErrorHandler errorHandler) { antlr.TokenStreamSelector selector = new antlr.TokenStreamSelector(); BooLexer lexer = new BooLexer(reader); lexer.setTabSize(TabSize); lexer.setFilename(readerName); lexer.setTokenObjectClass(TokenObjectClass); lexer.Initialize(selector, TabSize, TokenObjectClass); IndentTokenStreamFilter filter = new IndentTokenStreamFilter(lexer, WS, INDENT, DEDENT, EOS); selector.select(filter); BooParser parser = new BooParser(selector); parser.setFilename(readerName); parser.Error += errorHandler; Module module = parser.start(); module.Name = CreateModuleName(readerName); return(module); }