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