Class SimpleCharStream
java.lang.Object
org.tweetyproject.logics.rpcl.parser.rpclprobabilitydistributionparser.SimpleCharStream
An implementation of interface CharStream, where the stream is assumed to
contain only ASCII characters (without unicode processing).
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Position in buffer.static final boolean
Whether parser is static. -
Constructor Summary
ConstructorDescriptionSimpleCharStream
(InputStream dstream) ConstructorSimpleCharStream
(InputStream dstream, int startline, int startcolumn) ConstructorSimpleCharStream
(InputStream dstream, int startline, int startcolumn, int buffersize) ConstructorSimpleCharStream
(InputStream dstream, String encoding) ConstructorSimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn) ConstructorSimpleCharStream
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) ConstructorSimpleCharStream
(Reader dstream) ConstructorSimpleCharStream
(Reader dstream, int startline, int startcolumn) ConstructorSimpleCharStream
(Reader dstream, int startline, int startcolumn, int buffersize) Constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic void
adjustBeginLineColumn
(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.static void
backup
(int amount) Rewinds the input stream by a specified number of characters.static char
Startstatic void
Done()
Reset buffer when finished.static int
Retrieves the column number where the current token begins.static int
Retrieves the line number where the current token begins.static int
Deprecated.static int
Retrieves the column number where the current token ends.static int
Retrieves the line number where the current token ends.static String
GetImage()
Get token literal value.static int
getLine()
Deprecated.static char[]
GetSuffix
(int len) Get the suffix.static char
readChar()
Read a character.void
ReInit
(InputStream dstream) Reinitialisevoid
ReInit
(InputStream dstream, int startline, int startcolumn) Reinitialisevoid
ReInit
(InputStream dstream, int startline, int startcolumn, int buffersize) Reinitialisevoid
ReInit
(InputStream dstream, String encoding) Reinitialisevoid
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn) Reinitialisevoid
ReInit
(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) Reinitialisevoid
Reinitialisevoid
Reinitialisevoid
Reinitialise
-
Field Details
-
staticFlag
public static final boolean staticFlagWhether parser is static.- See Also:
-
bufpos
public static int bufposPosition in buffer.
-
-
Constructor Details
-
SimpleCharStream
Constructor- Parameters:
dstream
- the readerstartline
- start linestartcolumn
- start columnbuffersize
- buffer size
-
SimpleCharStream
Constructor- Parameters:
dstream
- the readerstartline
- start linestartcolumn
- start column
-
SimpleCharStream
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Constructor- Parameters:
dstream
- inout streamencoding
- the string encodingstartline
- start linestartcolumn
- start columnbuffersize
- buffer size- Throws:
UnsupportedEncodingException
- error
-
SimpleCharStream
Constructor- Parameters:
dstream
- inout streamstartline
- start linestartcolumn
- start columnbuffersize
- buffer size
-
SimpleCharStream
public SimpleCharStream(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Constructor- Parameters:
dstream
- inout streamencoding
- the string encodingstartline
- start linestartcolumn
- start column- Throws:
UnsupportedEncodingException
- error
-
SimpleCharStream
Constructor- Parameters:
dstream
- inout streamstartline
- start linestartcolumn
- start column
-
SimpleCharStream
Constructor- Parameters:
dstream
- inout streamencoding
- the string encoding- Throws:
UnsupportedEncodingException
- error
-
SimpleCharStream
-
-
Method Details
-
BeginToken
Start- Returns:
- begin token
- Throws:
IOException
- error
-
readChar
Read a character.- Returns:
- char
- Throws:
IOException
- error
-
getColumn
-
getLine
-
getEndColumn
public static int getEndColumn()Retrieves the column number where the current token ends.- Returns:
- The column number of the end of the current token.
-
getEndLine
public static int getEndLine()Retrieves the line number where the current token ends.- Returns:
- The line number of the end of the current token.
-
getBeginColumn
public static int getBeginColumn()Retrieves the column number where the current token begins.- Returns:
- The column number of the beginning of the current token.
-
getBeginLine
public static int getBeginLine()Retrieves the line number where the current token begins.- Returns:
- The line number of the beginning of the current token.
-
backup
public static void backup(int amount) Rewinds the input stream by a specified number of characters.This method allows you to move backwards in the input stream, effectively undoing the reading of a specified number of characters. This is useful when you need to backtrack after realizing that a token was read incorrectly or that more context is needed to parse the input properly.
- Parameters:
amount
- The number of characters to move backwards. This should be a positive integer.
-
ReInit
Reinitialise- Parameters:
dstream
- the readerstartline
- start linestartcolumn
- start columnbuffersize
- buffer size
-
ReInit
Reinitialise- Parameters:
dstream
- the readerstartline
- start linestartcolumn
- start column
-
ReInit
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) throws UnsupportedEncodingException Reinitialise- Parameters:
dstream
- inout streamencoding
- the string encodingstartline
- start linestartcolumn
- start columnbuffersize
- buffer size- Throws:
UnsupportedEncodingException
- error
-
ReInit
Reinitialise- Parameters:
dstream
- inout streamstartline
- start linestartcolumn
- start columnbuffersize
- buffer size
-
ReInit
Reinitialise- Parameters:
dstream
- inout streamencoding
- the string encoding- Throws:
UnsupportedEncodingException
- error
-
ReInit
-
ReInit
public void ReInit(InputStream dstream, String encoding, int startline, int startcolumn) throws UnsupportedEncodingException Reinitialise- Parameters:
dstream
- inout streamencoding
- the string encodingstartline
- start linestartcolumn
- start column- Throws:
UnsupportedEncodingException
- error
-
ReInit
Reinitialise- Parameters:
dstream
- inout streamstartline
- start linestartcolumn
- start column
-
GetImage
-
GetSuffix
public static char[] GetSuffix(int len) Get the suffix.- Parameters:
len
- length- Returns:
- suffix
-
Done
public static void Done()Reset buffer when finished. -
adjustBeginLineColumn
public static void adjustBeginLineColumn(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.- Parameters:
newLine
- linenewCol
- column
-