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
FieldsModifier and TypeFieldDescriptionstatic intPosition in buffer.static final booleanWhether parser is static. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCharStream(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 voidadjustBeginLineColumn(int newLine, int newCol) Method to adjust line and column numbers for the start of a token.static voidbackup(int amount) Rewinds the input stream by a specified number of characters.static charStartstatic voidDone()Reset buffer when finished.static intRetrieves the column number where the current token begins.static intRetrieves the line number where the current token begins.static intDeprecated.static intRetrieves the column number where the current token ends.static intRetrieves the line number where the current token ends.static StringGetImage()Get token literal value.static intgetLine()Deprecated.static char[]GetSuffix(int len) Get the suffix.static charreadChar()Read a character.voidReInit(InputStream dstream) ReinitialisevoidReInit(InputStream dstream, int startline, int startcolumn) ReinitialisevoidReInit(InputStream dstream, int startline, int startcolumn, int buffersize) ReinitialisevoidReInit(InputStream dstream, String encoding) ReinitialisevoidReInit(InputStream dstream, String encoding, int startline, int startcolumn) ReinitialisevoidReInit(InputStream dstream, String encoding, int startline, int startcolumn, int buffersize) ReinitialisevoidReinitialisevoidReinitialisevoidReinitialise
-
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
-