Class RpclCondensedProbabilityDistributionParserTokenManager
- All Implemented Interfaces:
RpclCondensedProbabilityDistributionParserConstants
-
Field Summary
Modifier and TypeFieldDescriptionstatic PrintStream
Debug output.static final String[]
Token literal values.static final String[]
Lexer state names.Fields inherited from interface org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.RpclCondensedProbabilityDistributionParserConstants
DEFAULT, EOF, MULTIPLICATOR, PROBABILITY, STRUCTURENAME, tokenImage
-
Constructor Summary
ConstructorDescriptionConstructs a newRpclCondensedProbabilityDistributionParserTokenManager
with the given input stream.RpclCondensedProbabilityDistributionParserTokenManager
(SimpleCharStream stream, int lexState) Constructs a newRpclCondensedProbabilityDistributionParserTokenManager
with the given input stream and lexical state. -
Method Summary
Modifier and TypeMethodDescriptionstatic Token
Get the next Token.static void
ReInit
(SimpleCharStream stream) Reinitializes the parser with a new input stream.static void
ReInit
(SimpleCharStream stream, int lexState) Reinitializes the parser with a new input stream and switches to the specified lexical state.static void
Sets the debug stream for the parser.static void
SwitchTo
(int lexState) Switches the parser to the specified lexical state.
-
Field Details
-
debugStream
Debug output. -
jjstrLiteralImages
Token literal values. -
lexStateNames
Lexer state names.
-
-
Constructor Details
-
RpclCondensedProbabilityDistributionParserTokenManager
Constructs a newRpclCondensedProbabilityDistributionParserTokenManager
with the given input stream.- Parameters:
stream
- TheSimpleCharStream
that provides the input for the token manager.- Throws:
TokenMgrError
- If the constructor is called more than once (i.e., the input stream is not null).
-
RpclCondensedProbabilityDistributionParserTokenManager
public RpclCondensedProbabilityDistributionParserTokenManager(SimpleCharStream stream, int lexState) Constructs a newRpclCondensedProbabilityDistributionParserTokenManager
with the given input stream and lexical state.- Parameters:
stream
- TheSimpleCharStream
that provides the input for the token manager.lexState
- The initial lexical state to which the token manager will switch.- Throws:
TokenMgrError
- If the primary constructor throws an error due to reinitialization.
-
-
Method Details
-
setDebugStream
Sets the debug stream for the parser.This method allows the user to specify a
PrintStream
that will be used to output debug information during the parsing process. By default, this stream might be set toSystem.out
orSystem.err
, but this method allows redirecting it to any other stream, such as a file stream or a custom logging stream.- Parameters:
ds
- ThePrintStream
to be used for debug output. This can be any validPrintStream
, such asSystem.out
orSystem.err
.
-
ReInit
Reinitializes the parser with a new input stream.This method resets the internal state of the parser and prepares it to parse a new input stream. It sets the initial values for matched positions, state counters, and the current lexical state. After reinitializing, it also resets the round counters used for parsing.
- Parameters:
stream
- The newSimpleCharStream
to be parsed. This stream provides the characters for token generation.
-
ReInit
Reinitializes the parser with a new input stream and switches to the specified lexical state.This method reinitializes the parser with a new input stream, as well as allowing for a specific lexical state to be set. It first calls the
ReInit(SimpleCharStream)
method to reset the parser's state with the provided stream, and then switches the parser to the given lexical state usingSwitchTo(int)
.- Parameters:
stream
- The newSimpleCharStream
to be parsed. This stream provides the characters for token generation.lexState
- The lexical state to switch to after reinitialization. The lexical state determines how the input is tokenized.
-
SwitchTo
public static void SwitchTo(int lexState) Switches the parser to the specified lexical state.This method allows the parser to change its lexical state, which affects how the input stream is tokenized. The lexical state defines the set of tokens that the parser recognizes at any given time. The method ensures that the lexical state provided is valid, otherwise, it throws a
TokenMgrError
with an appropriate error message.The valid lexical state range is between 0 (inclusive) and 1 (exclusive). If an invalid lexical state is provided (i.e., a state outside this range), the method throws an error and leaves the current lexical state unchanged.
- Parameters:
lexState
- The lexical state to switch to. Must be between 0 (inclusive) and 1 (exclusive).- Throws:
TokenMgrError
- if the specified lexical state is invalid (i.e., not within the range [0,1)).
-
getNextToken
-