org.jline.reader.EOFError Java Examples
The following examples show how to use
org.jline.reader.EOFError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InputParser.java From presto with Apache License 2.0 | 6 votes |
@Override public ParsedLine parse(String line, int cursor, ParseContext context) throws SyntaxError { String command = whitespace().trimFrom(line); if (command.isEmpty() || SPECIAL.contains(command.toLowerCase(ENGLISH))) { return new DefaultParser().parse(line, cursor, context); } StatementSplitter splitter = new StatementSplitter(line, STATEMENT_DELIMITERS); if (splitter.getCompleteStatements().isEmpty()) { throw new EOFError(-1, -1, null); } return new DefaultParser().parse(line, cursor, context); }
Example #2
Source File: SqlMultiLineParser.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override public ParsedLine parse(String line, int cursor, ParseContext context) { if (!line.trim().endsWith(EOF_CHARACTER) && context != ParseContext.COMPLETE) { throw new EOFError( -1, -1, "New line without EOF character.", NEW_LINE_PROMPT); } final ArgumentList parsedLine = (ArgumentList) super.parse(line, cursor, context); return new SqlArgumentList( parsedLine.line(), parsedLine.words(), parsedLine.wordIndex(), parsedLine.wordCursor(), parsedLine.cursor(), null, parsedLine.rawWordCursor(), parsedLine.rawWordLength()); }
Example #3
Source File: SqlMultiLineParser.java From flink with Apache License 2.0 | 6 votes |
@Override public ParsedLine parse(String line, int cursor, ParseContext context) { if (!line.trim().endsWith(EOF_CHARACTER) && context != ParseContext.COMPLETE) { throw new EOFError( -1, -1, "New line without EOF character.", NEW_LINE_PROMPT); } final ArgumentList parsedLine = (ArgumentList) super.parse(line, cursor, context); return new SqlArgumentList( parsedLine.line(), parsedLine.words(), parsedLine.wordIndex(), parsedLine.wordCursor(), parsedLine.cursor(), null, parsedLine.rawWordCursor(), parsedLine.rawWordLength()); }
Example #4
Source File: InteractiveMode.java From rdflint with MIT License | 6 votes |
/** * Overrided parse method. Need double return to perform command. */ @Override public ParsedLine parse(final String line, final int cursor, ParseContext context) { ParsedLine pl = super.parse(line, cursor, context); if (context != ParseContext.ACCEPT_LINE) { return pl; } if (line.length() == 0) { throw new EOFError(-1, -1, "No command", "command"); } if (!line.endsWith("\n") && line.trim().charAt(0) != ':') { throw new EOFError(-1, -1, "Single new line", "double newline"); } return pl; }
Example #5
Source File: SqlMultiLineParser.java From flink with Apache License 2.0 | 6 votes |
@Override public ParsedLine parse(String line, int cursor, ParseContext context) { if (!line.trim().endsWith(EOF_CHARACTER) && context != ParseContext.COMPLETE) { throw new EOFError( -1, -1, "New line without EOF character.", NEW_LINE_PROMPT); } final ArgumentList parsedLine = (ArgumentList) super.parse(line, cursor, context); return new SqlArgumentList( parsedLine.line(), parsedLine.words(), parsedLine.wordIndex(), parsedLine.wordCursor(), parsedLine.cursor(), null, parsedLine.rawWordCursor(), parsedLine.rawWordLength()); }
Example #6
Source File: SqlLineParserTest.java From sqlline with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSqlLineParserForWrongLines() { final DefaultParser parser = new SqlLineParser(new SqlLine()); final Parser.ParseContext acceptLine = Parser.ParseContext.ACCEPT_LINE; for (String line : WRONG_LINES) { try { parser.parse(line, line.length(), acceptLine); fail("Missing closing quote or semicolon for line " + line); } catch (EOFError eofError) { //ok } } }
Example #7
Source File: SqlLineParserTest.java From sqlline with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSqlLineParserForWrongLinesWithEmptyPrompt() { SqlLine sqlLine = new SqlLine(); sqlLine.getOpts().set(BuiltInProperty.PROMPT, ""); final DefaultParser parser = new SqlLineParser(sqlLine); final Parser.ParseContext acceptLine = Parser.ParseContext.ACCEPT_LINE; for (String line : WRONG_LINES) { try { parser.parse(line, line.length(), acceptLine); fail("Missing closing comment, quote or semicolon for line " + line); } catch (EOFError eofError) { //ok } } }
Example #8
Source File: InteractiveModeTest.java From rdflint with MIT License | 4 votes |
@Test(expected = EOFError.class) public void interactiveParserNoCommand() throws Exception { InteractiveMode.InteractiveParser parser = new InteractiveMode.InteractiveParser(); parser.parse("", 0, ParseContext.ACCEPT_LINE); }
Example #9
Source File: InteractiveModeTest.java From rdflint with MIT License | 4 votes |
@Test(expected = EOFError.class) public void interactiveParserNoDoubleReturn() throws Exception { InteractiveMode.InteractiveParser parser = new InteractiveMode.InteractiveParser(); parser.parse("select", 0, ParseContext.ACCEPT_LINE); }
Example #10
Source File: SqlLineParser.java From sqlline with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ParsedLine parse(final String line, final int cursor, ParseContext context) { try { if (sqlLine.getOpts().getUseLineContinuation() && !sqlLine.isPrompting()) { eofOnUnclosedQuote(true); eofOnEscapedNewLine(true); } else { eofOnUnclosedQuote(false); eofOnEscapedNewLine(false); return super.parse(line, cursor, context); } final SqlLineArgumentList argumentList = parseState(line, cursor, context); if (argumentList.state == SqlParserState.NEW_LINE) { throw new EOFError(-1, -1, argumentList.state.message, argumentList.supplier.get()); } if (context != ParseContext.COMPLETE) { switch (argumentList.state) { case QUOTED: case MULTILINE_COMMENT: case ROUND_BRACKET_BALANCE_FAILED: case SQUARE_BRACKET_BALANCE_FAILED: case SEMICOLON_REQUIRED: throw new EOFError(-1, -1, argumentList.state.message, argumentList.supplier.get()); } } if (argumentList.state == SqlParserState.LINE_CONTINUES) { throw new EOFError(-1, -1, argumentList.state.message, argumentList.supplier.get()); } return argumentList; } catch (Exception e) { if (e instanceof EOFError) { // line continuation is expected throw e; } sqlLine.handleException(e); return super.parse(line, cursor, context); } }