public boolean parseFile(File dir, String file) { InputState inputState = null; try { FileInputStream fis = new FileInputStream(new File(dir, file)); currentFile = file; // Create a scanner that reads from the input stream passed to us inputState = new InputState(fis); TextLexer lexer = new TextLexer(inputState); lexer.setFilename(file); lexer.setTokenObjectClass("jplag.ParserToken"); // Create a parser that reads from the scanner TextParser parser = new TextParser(lexer); parser.setFilename(file); parser.parser = this;// Added by Emeric 26.01.05 BAD // start parsing at the compilationUnit rule parser.file(); // close file fis.close(); } catch (Exception e) { getProgram().addError(" Parsing Error in '" + file + "' (line " + (inputState != null ? "" + inputState.getLine() : "") + "):\n " + e.getMessage()); return false; } return true; }
public boolean parseFile(File dir, String file) { InputState inputState = null; try { FileInputStream fis = new FileInputStream(new File(dir, file)); currentFile = file; // Create a scanner that reads from the input stream passed to us inputState = new InputState(fis); JLexer lexer = new JLexer(inputState); lexer.setFilename(file); lexer.setTokenObjectClass("jplag.ParserToken"); // Create a parser that reads from the scanner JRecognizer parser = new JRecognizer(lexer); parser.setFilename(file); parser.parser = this; // start parsing at the compilationUnit rule parser.compilationUnit(); // close file fis.close(); } catch (Exception e) { getProgram().addError( " Parsing Error in '" + file + "':\n" + " Parse error at line " + (inputState != null ? "" + inputState.getLine() : "UNKNOWN") + ", column " + (inputState != null ? "" + inputState.tokColumn : "UNKNOWN") + ": " + e.getMessage() + "\n"); return false; } return true; }