KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > jsp > ast > CharStream


1 /* Generated By:JavaCC: Do not edit this line. CharStream.java Version 3.0 */
2 /**
3  * JSP Parser for PMD.
4  * @author Pieter – Application Engineers NV/SA – http://www.ae.be
5  */

6
7 package net.sourceforge.pmd.jsp.ast;
8
9 /**
10  * This interface describes a character stream that maintains line and
11  * column number positions of the characters. It also has the capability
12  * to backup the stream to some extent. An implementation of this
13  * interface is used in the TokenManager implementation generated by
14  * JavaCCParser.
15  * <p/>
16  * All the methods except backup can be implemented in any fashion. backup
17  * needs to be implemented correctly for the correct operation of the lexer.
18  * Rest of the methods are all used to get information like line number,
19  * column number and the String that constitutes a token and are not used
20  * by the lexer. Hence their implementation won't affect the generated lexer's
21  * operation.
22  */

23
24 public interface CharStream extends net.sourceforge.pmd.ast.CharStream {
25
26     /**
27      * Returns the next character from the selected input. The method
28      * of selecting the input is the responsibility of the class
29      * implementing this interface. Can throw any java.io.IOException.
30      */

31     char readChar() throws java.io.IOException JavaDoc;
32
33     /**
34      * Returns the column position of the character last read.
35      *
36      * @see #getEndColumn
37      * @deprecated
38      */

39     int getColumn();
40
41     /**
42      * Returns the line number of the character last read.
43      *
44      * @see #getEndLine
45      * @deprecated
46      */

47     int getLine();
48
49     /**
50      * Returns the column number of the last character for current token (being
51      * matched after the last call to BeginTOken).
52      */

53     int getEndColumn();
54
55     /**
56      * Returns the line number of the last character for current token (being
57      * matched after the last call to BeginTOken).
58      */

59     int getEndLine();
60
61     /**
62      * Returns the column number of the first character for current token (being
63      * matched after the last call to BeginTOken).
64      */

65     int getBeginColumn();
66
67     /**
68      * Returns the line number of the first character for current token (being
69      * matched after the last call to BeginTOken).
70      */

71     int getBeginLine();
72
73     /**
74      * Backs up the input stream by amount steps. Lexer calls this method if it
75      * had already read some characters, but could not use them to match a
76      * (longer) token. So, they will be used again as the prefix of the next
77      * token and it is the implemetation's responsibility to do this right.
78      */

79     void backup(int amount);
80
81     /**
82      * Returns the next character that marks the beginning of the next token.
83      * All characters must remain in the buffer between two successive calls
84      * to this method to implement backup correctly.
85      */

86     char BeginToken() throws java.io.IOException JavaDoc;
87
88     /**
89      * Returns a string made up of characters from the marked token beginning
90      * to the current buffer position. Implementations have the choice of returning
91      * anything that they want to. For example, for efficiency, one might decide
92      * to just return null, which is a valid implementation.
93      */

94     String JavaDoc GetImage();
95
96     /**
97      * Returns an array of characters that make up the suffix of length 'len' for
98      * the currently matched token. This is used to build up the matched string
99      * for use in actions in the case of MORE. A simple and inefficient
100      * implementation of this is as follows :
101      * <p/>
102      * {
103      * String t = GetImage();
104      * return t.substring(t.length() - len, t.length()).toCharArray();
105      * }
106      */

107     char[] GetSuffix(int len);
108
109     /**
110      * The lexer calls this function to indicate that it is done with the stream
111      * and hence implementations can free any resources held by this class.
112      * Again, the body of this function can be just empty and it will not
113      * affect the lexer's operation.
114      */

115     void Done();
116
117 }
118
Popular Tags