1 /*
2  * Copyright (c) 2002-2016, the original author or authors.
3  *
4  * This software is distributable under the BSD license. See the terms of the
5  * BSD license in the documentation provided with this software.
6  *
7  * http://www.opensource.org/licenses/bsd-license.php
8  */
9 package jdk.internal.org.jline.reader;
10 
11 public interface Parser {
12 
parse(String line, int cursor, ParseContext context)13     ParsedLine parse(String line, int cursor, ParseContext context) throws SyntaxError;
14 
parse(String line, int cursor)15     default ParsedLine parse(String line, int cursor) throws SyntaxError {
16         return parse(line, cursor, ParseContext.UNSPECIFIED);
17     }
18 
19     enum ParseContext {
20         UNSPECIFIED,
21 
22         /** Try a real "final" parse.
23          * May throw EOFError in which case we have incomplete input.
24          */
25         ACCEPT_LINE,
26 
27         /** Parse to find completions (typically after a Tab).
28          * We should tolerate and ignore errors.
29          */
30         COMPLETE,
31 
32         /** Called when we need to update the secondary prompts.
33          * Specifically, when we need the 'missing' field from EOFError,
34          * which is used by a "%M" in a prompt pattern.
35          */
36         SECONDARY_PROMPT
37     }
38 }
39