001: /* Generated By:JavaCC: Do not edit this line. CharStream.java Version 3.0 */
002: /**
003: * JSP Parser for PMD.
004: * @author Pieter, Application Engineers NV/SA, http://www.ae.be
005: */package net.sourceforge.pmd.jsp.ast;
006:
007: /**
008: * This interface describes a character stream that maintains line and
009: * column number positions of the characters. It also has the capability
010: * to backup the stream to some extent. An implementation of this
011: * interface is used in the TokenManager implementation generated by
012: * JavaCCParser.
013: * <p/>
014: * All the methods except backup can be implemented in any fashion. backup
015: * needs to be implemented correctly for the correct operation of the lexer.
016: * Rest of the methods are all used to get information like line number,
017: * column number and the String that constitutes a token and are not used
018: * by the lexer. Hence their implementation won't affect the generated lexer's
019: * operation.
020: */
021:
022: public interface CharStream extends net.sourceforge.pmd.ast.CharStream {
023:
024: /**
025: * Returns the next character from the selected input. The method
026: * of selecting the input is the responsibility of the class
027: * implementing this interface. Can throw any java.io.IOException.
028: */
029: char readChar() throws java.io.IOException;
030:
031: /**
032: * Returns the column position of the character last read.
033: *
034: * @see #getEndColumn
035: * @deprecated
036: */
037: int getColumn();
038:
039: /**
040: * Returns the line number of the character last read.
041: *
042: * @see #getEndLine
043: * @deprecated
044: */
045: int getLine();
046:
047: /**
048: * Returns the column number of the last character for current token (being
049: * matched after the last call to BeginTOken).
050: */
051: int getEndColumn();
052:
053: /**
054: * Returns the line number of the last character for current token (being
055: * matched after the last call to BeginTOken).
056: */
057: int getEndLine();
058:
059: /**
060: * Returns the column number of the first character for current token (being
061: * matched after the last call to BeginTOken).
062: */
063: int getBeginColumn();
064:
065: /**
066: * Returns the line number of the first character for current token (being
067: * matched after the last call to BeginTOken).
068: */
069: int getBeginLine();
070:
071: /**
072: * Backs up the input stream by amount steps. Lexer calls this method if it
073: * had already read some characters, but could not use them to match a
074: * (longer) token. So, they will be used again as the prefix of the next
075: * token and it is the implemetation's responsibility to do this right.
076: */
077: void backup(int amount);
078:
079: /**
080: * Returns the next character that marks the beginning of the next token.
081: * All characters must remain in the buffer between two successive calls
082: * to this method to implement backup correctly.
083: */
084: char BeginToken() throws java.io.IOException;
085:
086: /**
087: * Returns a string made up of characters from the marked token beginning
088: * to the current buffer position. Implementations have the choice of returning
089: * anything that they want to. For example, for efficiency, one might decide
090: * to just return null, which is a valid implementation.
091: */
092: String GetImage();
093:
094: /**
095: * Returns an array of characters that make up the suffix of length 'len' for
096: * the currently matched token. This is used to build up the matched string
097: * for use in actions in the case of MORE. A simple and inefficient
098: * implementation of this is as follows :
099: * <p/>
100: * {
101: * String t = GetImage();
102: * return t.substring(t.length() - len, t.length()).toCharArray();
103: * }
104: */
105: char[] GetSuffix(int len);
106:
107: /**
108: * The lexer calls this function to indicate that it is done with the stream
109: * and hence implementations can free any resources held by this class.
110: * Again, the body of this function can be just empty and it will not
111: * affect the lexer's operation.
112: */
113: void Done();
114:
115: }
|