private static void checkState(boolean condition, int lineNumber, String line) { if (!condition) { throw new RecognitionException(lineNumber, "Cannot parse directive at line " + lineNumber + ":\n" + line); } }
private static void checkState(boolean condition, int lineNumber, String line) { if (!condition) { throw new RecognitionException(lineNumber, "Cannot parse directive at line " + lineNumber + ":\n" + line); } }
private static char[] fileToCharArray(File file, Charset charset) { try { return Files.toString(file, charset).toCharArray(); } catch (IOException e) { throw new RecognitionException(0, e.getMessage(), e); } }
private static char[] fileToCharArray(File file, Charset charset) { try { return new String(Files.readAllBytes(Paths.get(file.getPath())), charset).toCharArray(); } catch (IOException e) { throw new RecognitionException(0, e.getMessage(), e); } }
private static char[] fileToCharArray(File file, Charset charset) { try { return new String(Files.readAllBytes(Paths.get(file.getPath())), charset).toCharArray(); } catch (IOException e) { throw new RecognitionException(0, e.getMessage(), e); } }
private static char[] fileToCharArray(File file, Charset charset) { FileInputStream is = null; try { is = new FileInputStream(file); return IOUtils.toCharArray(is, charset.name()); } catch (IOException e) { throw new RecognitionException(0, e.getMessage(), e); } finally { IOUtils.closeQuietly(is); } }
private static RecognitionException exception(Tree tree, Throwable cause) { return new RecognitionException(((PHPTree) tree).getLine(), "Failed to build CFG", cause); }
private static void checkFullFidelity(Tree tree, String inputString) { String resultString = expressionToString(tree); if (!inputString.equals(resultString)) { if (inputString.startsWith(resultString)) { String message = "Only beginning of the input string is parsed: " + resultString; throw new RecognitionException(0, message); } else { String message = "Some tokens are lost. See result tree string: " + resultString; throw new RecognitionException(0, message); } } } }
public AstNode parse(String source) { try { lexer.lex(source); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
public AstNode parse(File file) { try { lexer.lex(file); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
public AstNode parse(String source) { try { lexer.lex(source); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
public AstNode parse(File file) { try { lexer.lex(file); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
public AstNode parse(File file) { try { lexer.lex(file); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
public AstNode parse(String source) { try { lexer.lex(source); } catch (LexerException e) { throw new RecognitionException(e); } return parse(lexer.getTokens()); }
private void parseTillEof(String input) { PHPTree tree = (PHPTree) actual.parse(input); InternalSyntaxToken lastToken = (InternalSyntaxToken) tree.getLastToken(); if (lastToken.toIndex() != input.length()) { throw new RecognitionException( 0, "Did not match till EOF, but till line " + lastToken.line() + ": token \"" + lastToken.text() + "\""); } }
private AstNode parse(Text input) { char[] chars = ((AbstractText) input).toChars(); ParsingResult result = parseRunner.parse(chars); if (result.isMatched()) { return AstCreator.create(result, input); } else { ParseError parseError = result.getParseError(); InputBuffer inputBuffer = parseError.getInputBuffer(); int line = inputBuffer.getPosition(parseError.getErrorIndex()).getLine(); String message = new ParseErrorFormatter2().format(parseError); throw new RecognitionException(line, message); } }
private N parse(Input input) { ParsingResult result = parseRunner.parse(input.input()); if (!result.isMatched()) { ParseError parseError = result.getParseError(); InputBuffer inputBuffer = parseError.getInputBuffer(); int line = inputBuffer.getPosition(parseError.getErrorIndex()).getLine(); String message = new ParseErrorFormatter().format(parseError); throw new RecognitionException(line, message); } return syntaxTreeCreator.create(result.getParseTreeRoot(), input); }
private N parse(Input input) { ParsingResult result = parseRunner.parse(input.input()); if (!result.isMatched()) { ParseError parseError = result.getParseError(); InputBuffer inputBuffer = parseError.getInputBuffer(); int line = inputBuffer.getPosition(parseError.getErrorIndex()).getLine(); String message = new ParseErrorFormatter().format(parseError); throw new RecognitionException(line, message); } return syntaxTreeCreator.create(result.getParseTreeRoot(), input); }
private AstNode parse(Input input) { ParsingResult result = parseRunner.parse(input.input()); if (!result.isMatched()) { ParseError parseError = result.getParseError(); InputBuffer inputBuffer = parseError.getInputBuffer(); int line = inputBuffer.getPosition(parseError.getErrorIndex()).getLine(); String message = new ParseErrorFormatter().format(parseError); throw new RecognitionException(line, message); } AstNode astNode = syntaxTreeCreator.create(result.getParseTreeRoot(), input); astNodeSanitzer.sanitize(astNode); return astNode; }
private AstNode parse(Input input) { ParsingResult result = parseRunner.parse(input.input()); if (!result.isMatched()) { ParseError parseError = result.getParseError(); InputBuffer inputBuffer = parseError.getInputBuffer(); int line = inputBuffer.getPosition(parseError.getErrorIndex()).getLine(); String message = new ParseErrorFormatter().format(parseError); throw new RecognitionException(line, message); } AstNode astNode = syntaxTreeCreator.create(result.getParseTreeRoot(), input); astNodeSanitzer.sanitize(astNode); return astNode; }