Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CharStream |
|
| 1.0;1 |
1 | /* Generated By:JavaCC: Do not edit this line. CharStream.java Version 4.1 */ | |
2 | /* JavaCCOptions:STATIC=false */ | |
3 | package org.webmacro.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 interface CharStream { | |
21 | ||
22 | /** | |
23 | * Returns the next character from the selected input. The method | |
24 | * of selecting the input is the responsibility of the class | |
25 | * implementing this interface. Can throw any java.io.IOException. | |
26 | */ | |
27 | char readChar() throws java.io.IOException; | |
28 | ||
29 | /** | |
30 | * Returns the column position of the character last read. | |
31 | * @deprecated | |
32 | * @see #getEndColumn | |
33 | */ | |
34 | int getColumn(); | |
35 | ||
36 | /** | |
37 | * Returns the line number of the character last read. | |
38 | * @deprecated | |
39 | * @see #getEndLine | |
40 | */ | |
41 | int getLine(); | |
42 | ||
43 | /** | |
44 | * Returns 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 | * Returns 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 | * Returns the column number of the first character for current token (being | |
57 | * matched after the last call to BeginTOken). | |
58 | */ | |
59 | int getBeginColumn(); | |
60 | ||
61 | /** | |
62 | * Returns the line number of the first character for current token (being | |
63 | * matched after the last call to BeginTOken). | |
64 | */ | |
65 | int getBeginLine(); | |
66 | ||
67 | /** | |
68 | * Backs up the input stream by amount steps. Lexer calls this method if it | |
69 | * had already read some characters, but could not use them to match a | |
70 | * (longer) token. So, they will be used again as the prefix of the next | |
71 | * token and it is the implemetation's responsibility to do this right. | |
72 | */ | |
73 | void backup(int amount); | |
74 | ||
75 | /** | |
76 | * Returns the next character that marks the beginning of the next token. | |
77 | * All characters must remain in the buffer between two successive calls | |
78 | * to this method to implement backup correctly. | |
79 | */ | |
80 | char BeginToken() throws java.io.IOException; | |
81 | ||
82 | /** | |
83 | * Returns a string made up of characters from the marked token beginning | |
84 | * to the current buffer position. Implementations have the choice of returning | |
85 | * anything that they want to. For example, for efficiency, one might decide | |
86 | * to just return null, which is a valid implementation. | |
87 | */ | |
88 | String GetImage(); | |
89 | ||
90 | /** | |
91 | * Returns an array of characters that make up the suffix of length 'len' for | |
92 | * the currently matched token. This is used to build up the matched string | |
93 | * for use in actions in the case of MORE. A simple and inefficient | |
94 | * implementation of this is as follows : | |
95 | * | |
96 | * { | |
97 | * String t = GetImage(); | |
98 | * return t.substring(t.length() - len, t.length()).toCharArray(); | |
99 | * } | |
100 | */ | |
101 | char[] GetSuffix(int len); | |
102 | ||
103 | /** | |
104 | * The lexer calls this function to indicate that it is done with the stream | |
105 | * and hence implementations can free any resources held by this class. | |
106 | * Again, the body of this function can be just empty and it will not | |
107 | * affect the lexer's operation. | |
108 | */ | |
109 | void Done(); | |
110 | ||
111 | } | |
112 | /* JavaCC - OriginalChecksum=995d31c169f1d3d55e372131438a66de (do not edit this line) */ |