Package de.jplag.c
Class JavaCharStream
java.lang.Object
de.jplag.c.AbstractCharStream
de.jplag.c.JavaCharStream
- All Implemented Interfaces:
CharStream
An implementation of interface CharStream, where the stream is assumed to
contain only ASCII characters (with java-like unicode escape processing).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intPredefined buffer sizeFields inherited from class de.jplag.c.AbstractCharStream
available, buffer, bufpos, bufsize, DEFAULT_BUF_SIZE, inBuf, maxNextCharInd, tokenBegin -
Constructor Summary
ConstructorsConstructorDescriptionJavaCharStream(InputStream dstream, String encoding) Constructor.JavaCharStream(InputStream dstream, String encoding, int startline, int startcolumn) Constructor.JavaCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Constructor.JavaCharStream(Reader dstream) Constructor.JavaCharStream(Reader dstream, int startline, int startcolumn) Constructor.JavaCharStream(Reader dstream, int startline, int startcolumn, int buffersize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptioncharvoiddone()The lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class.protected voidfillBuff()charreadChar()Get the next character from the selected input.voidreInit(InputStream dstream, String encoding) Reinitialise.voidreInit(InputStream dstream, String encoding, int startline, int startcolumn) Reinitialise.voidreInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitialise.voidReinitialise.voidReinitialise.voidReinitialise.protected voidClose the underlying stream.protected intstreamRead(char[] buffer, int offset, int len) Read from the underlying stream.Methods inherited from class de.jplag.c.AbstractCharStream
adjustBeginLineColumn, backup, expandBuff, getBeginColumn, getBeginLine, getBufSizeAfterExpansion, getColumn, getEndColumn, getEndLine, getImage, getLine, getSuffix, getTabSize, internalAdjustBuffSize, internalSetBufLineColumn, internalUpdateLineColumn, isTrackLineColumn, reInit, setTabSize, setTrackLineColumn
-
Field Details
-
NEXTCHAR_BUF_SIZE
protected static final int NEXTCHAR_BUF_SIZEPredefined buffer size- See Also:
-
-
Constructor Details
-
JavaCharStream
Constructor. -
JavaCharStream
Constructor. -
JavaCharStream
Constructor. -
JavaCharStream
public JavaCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructor.- Throws:
UnsupportedEncodingException
-
JavaCharStream
public JavaCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Constructor.- Throws:
UnsupportedEncodingException
-
JavaCharStream
Constructor.- Throws:
UnsupportedEncodingException
-
-
Method Details
-
streamRead
Description copied from class:AbstractCharStreamRead from the underlying stream.- Specified by:
streamReadin classAbstractCharStream- Parameters:
buffer- the buffer to be filledoffset- The offset into the buffer. 0-basedlen- Number of chars to read.- Returns:
- Number of effective chars read, or -1 on error.
- Throws:
IOException
-
streamClose
Description copied from class:AbstractCharStreamClose the underlying stream.- Specified by:
streamClosein classAbstractCharStream- Throws:
IOException- If closing fails.
-
fillBuff
- Overrides:
fillBuffin classAbstractCharStream- Throws:
IOException
-
beginToken
- Specified by:
beginTokenin interfaceCharStream- Overrides:
beginTokenin classAbstractCharStream- Returns:
- the next character that marks the beginning of the next token. All characters must remain in the buffer between two successive calls to this method to implement backup correctly.
- Throws:
IOException
-
readChar
Description copied from interface:CharStreamGet the next character from the selected input. The method of selecting the input is the responsibility of the class implementing this interface.- Specified by:
readCharin interfaceCharStream- Overrides:
readCharin classAbstractCharStream- Returns:
- the next character from the selected input
- Throws:
IOException- on IO error
-
reInit
Reinitialise. -
reInit
Reinitialise. -
reInit
Reinitialise. -
reInit
Reinitialise.- Throws:
UnsupportedEncodingException
-
reInit
public void reInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitialise.- Throws:
UnsupportedEncodingException
-
reInit
public void reInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitialise.- Throws:
UnsupportedEncodingException
-
done
public void done()Description copied from interface:CharStreamThe lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class. Again, the body of this function can be just empty and it will not affect the lexer's operation.- Specified by:
donein interfaceCharStream- Overrides:
donein classAbstractCharStream
-