Package org.tweetyproject.lp.asp.parser
Class SimpleCharStream
java.lang.Object
org.tweetyproject.lp.asp.parser.SimpleCharStream
An implementation of interface CharStream, where the stream is assumed to
contain only ASCII characters (without unicode processing).
-
Field Summary
Modifier and TypeFieldDescriptionint
Position in buffer.static final boolean
Whether parser is static. -
Constructor Summary
ConstructorDescriptionSimpleCharStream
(InputStream dstream) Constructs aSimpleCharStream
with the specified input stream.SimpleCharStream
(InputStream dstream, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified input stream, starting line, and starting column.SimpleCharStream
(InputStream dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size.SimpleCharStream
(InputStream dstream, String encoding) Constructs aSimpleCharStream
with the specified input stream, character encoding, and a default buffer size of 4096 characters.SimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified input stream, character encoding, starting line, and starting column.SimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified input stream, character encoding, starting line, starting column, and buffer size.SimpleCharStream
(Reader dstream) Constructs aSimpleCharStream
with the specified input reader.SimpleCharStream
(Reader dstream, int startline, int startcolumn) Constructs aSimpleCharStream
with the specified input reader, starting line, and starting column.SimpleCharStream
(Reader dstream, int startline, int startcolumn, int buffersize) Constructs aSimpleCharStream
with the specified input reader, starting line, starting column, and buffer size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustBeginLineColumn
(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.void
backup
(int amount) backup by amountchar
Return beginvoid
Done()
Reset buffer when finished.int
Get token beginning column numberint
Get token beginning line numberint
Deprecated.int
Get token end column numberint
Get token end line numberGetImage()
Get token literal value.int
getLine()
Deprecated.char[]
GetSuffix
(int len) Get the suffix.char
readChar()
Read a charactervoid
ReInit
(InputStream dstream) Reinitializes the character stream with the specified input stream.void
ReInit
(InputStream dstream, int startline, int startcolumn) Reinitializes the character stream with the specified input stream, starting line, and starting column.void
ReInit
(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size.void
ReInit
(InputStream dstream, String encoding) Reinitializes the character stream with the specified input stream and character encoding.void
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn) Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column.void
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.void
Reinitializes thisSimpleCharStream
with a new input reader.void
Reinitializes thisSimpleCharStream
with a new input reader, starting line, and starting column.void
Reinitializes thisSimpleCharStream
with a new input reader, starting line, starting column, and buffer size.
-
Field Details
-
staticFlag
public static final boolean staticFlagWhether parser is static.- See Also:
-
bufpos
public int bufposPosition in buffer.
-
-
Constructor Details
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input reader, starting line, starting column, and buffer size.- Parameters:
dstream
- TheReader
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheReader
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheReader
to read character data from.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructs aSimpleCharStream
with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Constructs aSimpleCharStream
with the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
SimpleCharStream
Constructs aSimpleCharStream
with the specified input stream, character encoding, and a default buffer size of 4096 characters. The starting line and column are set to 1.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
-
Method Details
-
BeginToken
Return begin- Returns:
- a char
- Throws:
IOException
- error
-
readChar
Read a character- Returns:
- a character
- Throws:
IOException
- error
-
getColumn
-
getLine
-
getEndColumn
public int getEndColumn()Get token end column number- Returns:
- token end column number
-
getEndLine
public int getEndLine()Get token end line number- Returns:
- token end line number
-
getBeginColumn
public int getBeginColumn()Get token beginning column number- Returns:
- Get token beginning column number
-
getBeginLine
public int getBeginLine()Get token beginning line number- Returns:
- Get token beginning line number
-
backup
public void backup(int amount) backup by amount- Parameters:
amount
- the amount
-
ReInit
Reinitializes thisSimpleCharStream
with a new input reader, starting line, starting column, and buffer size.- Parameters:
dstream
- TheReader
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.
-
ReInit
Reinitializes thisSimpleCharStream
with a new input reader, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheReader
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).
-
ReInit
Reinitializes thisSimpleCharStream
with a new input reader. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheReader
to read character data from.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitializes the character stream with the specified input stream, character encoding, starting line, starting column, and buffer size.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream, starting line, starting column, and buffer size. The character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).buffersize
- The size of the buffer used to read characters.
-
ReInit
Reinitializes the character stream with the specified input stream and character encoding. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream. The starting line and column are set to 1, and the buffer size is set to 4096 characters by default. The character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitializes the character stream with the specified input stream, character encoding, starting line, and starting column. The buffer size is set to 4096 characters by default.- Parameters:
dstream
- TheInputStream
to read character data from.encoding
- The character encoding to use. Ifnull
, the default encoding is used.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).- Throws:
UnsupportedEncodingException
- If the specified encoding is not supported.
-
ReInit
Reinitializes the character stream with the specified input stream, starting line, and starting column. The buffer size is set to 4096 characters by default and the character encoding is set to the platform's default.- Parameters:
dstream
- TheInputStream
to read character data from.startline
- The line number to start reading from (1-based).startcolumn
- The column number to start reading from (1-based).
-
GetImage
-
GetSuffix
public char[] GetSuffix(int len) Get the suffix.- Parameters:
len
- length- Returns:
- char
-
Done
public void Done()Reset buffer when finished. -
adjustBeginLineColumn
public void adjustBeginLineColumn(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.- Parameters:
newLine
- new linenewCol
- the column
-