1 /* Generated by: ParserGeneratorCC: Do not edit this line. CharStream.java Version 1.1 */
2 /* ParserGeneratorCCOptions:SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
3 package org.apache.commons.jexl3.parser;
4
5 /**
6 * This interface describes a character stream that maintains line and
7 * column number positions of the characters. It also has the capability
8 * to backup the stream to some extent. An implementation of this
9 * interface is used in the TokenManager implementation generated by
10 * JavaCCParser.
11 *
12 * All the methods except backup can be implemented in any fashion. backup
13 * needs to be implemented correctly for the correct operation of the lexer.
14 * Rest of the methods are all used to get information like line number,
15 * column number and the String that constitutes a token and are not used
16 * by the lexer. Hence their implementation won't affect the generated lexer's
17 * operation.
18 */
19
20 public
21 interface CharStream {
22 /**
23 * Get the next character from the selected input. The method
24 * of selecting the input is the responsibility of the class
25 * implementing this interface.
26 * @return the next character from the selected input
27 * @throws java.io.IOException on IO error
28 */
29 char readChar() throws java.io.IOException;
30
31 /**
32 * @return the column number of the first character for current token (being
33 * matched after the last call to beginToken).
34 */
35 int getBeginColumn();
36
37 /**
38 * @return the line number of the first character for current token (being
39 * matched after the last call to BeginToken).
40 */
41 int getBeginLine();
42
43 /**
44 * @return the column number of the last character for current token (being
45 * matched after the last call to BeginToken).
46 */
47 int getEndColumn();
48
49 /**
50 * @return the line number of the last character for current token (being
51 * matched after the last call to BeginToken).
52 */
53 int getEndLine();
54
55 /**
56 * Backs up the input stream by amount steps. Lexer calls this method if it
57 * had already read some characters, but could not use them to match a
58 * (longer) token. So, they will be used again as the prefix of the next
59 * token and it is the implemetation's responsibility to do this right.
60 * @param amount Number of chars to back up.
61 */
62 void backup(int amount);
63
64 /**
65 * @return the next character that marks the beginning of the next token.
66 * All characters must remain in the buffer between two successive calls
67 * to this method to implement backup correctly.
68 */
69 char beginToken() throws java.io.IOException;
70
71 /**
72 * @return a string made up of characters from the marked token beginning
73 * to the current buffer position. Implementations have the choice of returning
74 * anything that they want to. For example, for efficiency, one might decide
75 * to just return null, which is a valid implementation.
76 */
77 String getImage();
78
79 /**
80 * @return an array of characters that make up the suffix of length 'len' for
81 * the currently matched token. This is used to build up the matched string
82 * for use in actions in the case of MORE. A simple and inefficient
83 * implementation of this is as follows:
84 * <pre>
85 * {
86 * String t = getImage();
87 * return t.substring(t.length() - len, t.length()).toCharArray();
88 * }
89 * </pre>
90 */
91 char[] getSuffix(int len);
92
93 /**
94 * The lexer calls this function to indicate that it is done with the stream
95 * and hence implementations can free any resources held by this class.
96 * Again, the body of this function can be just empty and it will not
97 * affect the lexer's operation.
98 */
99 void done();
100
101 // Getters and setters
102
103 /**
104 * @return Current tab size.
105 */
106 int getTabSize();
107
108 /**
109 * Set the tab size to use.
110 * @param i spaces per tab
111 */
112 void setTabSize(int i);
113
114 /**
115 * @return <code>true</code> if line number and column numbers should be tracked.
116 */
117 boolean isTrackLineColumn();
118
119 /**
120 * Enable or disable line number and column number tracking.
121 * @param trackLineColumn <code>true</code> to track it, <code>false</code> to not do it.
122 */
123 void setTrackLineColumn(boolean trackLineColumn);
124 }
125 /* ParserGeneratorCC - OriginalChecksum=339f3e12a400872cfc11d078eb9ad32e (do not edit this line) */