Class POParserTokenManager
-
Field Summary
Modifier and TypeFieldDescriptionDebug output.static final String[]
Token literal values.static final String[]
Lexer state names.Fields inherited from interface org.tweetyproject.preferences.io.POParserConstants
DEFAULT, ELEMENT, EOF, EOL, LBRA, RBRA, REL, tokenImage
-
Constructor Summary
ConstructorDescriptionPOParserTokenManager
(SimpleCharStream stream) Constructor that initializes the POParserTokenManager with a provided SimpleCharStream.POParserTokenManager
(SimpleCharStream stream, int lexState) Constructor that initializes the POParserTokenManager with a provided SimpleCharStream and a specific lexical state. -
Method Summary
Modifier and TypeMethodDescriptionReturn the next tokenvoid
ReInit
(SimpleCharStream stream) Reinitializes the parser's state with a new input stream.void
ReInit
(SimpleCharStream stream, int lexState) Reinitializes the parser's state with a new input stream and switches to the specified lexical state.void
Sets the debug stream for the parser.void
SwitchTo
(int lexState) Switches the lexer to the specified lexical state.
-
Field Details
-
debugStream
Debug output. -
jjstrLiteralImages
Token literal values. -
lexStateNames
Lexer state names.
-
-
Constructor Details
-
POParserTokenManager
Constructor that initializes the POParserTokenManager with a provided SimpleCharStream.This constructor initializes the lexical analyzer with the given character stream, which will be used for tokenization. If the provided SimpleCharStream is static, an error is thrown because a non-static lexical analyzer cannot use a static CharStream.
- Parameters:
stream
- The input character stream that the lexer will read from.- Throws:
Error
- if a static SimpleCharStream is used with a non-static lexical analyzer.
-
POParserTokenManager
Constructor that initializes the POParserTokenManager with a provided SimpleCharStream and a specific lexical state.This constructor initializes the lexical analyzer with the given character stream and sets the initial lexical state. It calls the base constructor to initialize the stream and then switches the lexical analyzer to the specified state.
- Parameters:
stream
- The input character stream that the lexer will read from.lexState
- The initial lexical state to switch to.- Throws:
Error
- if a static SimpleCharStream is used with a non-static lexical analyzer.
-
-
Method Details
-
setDebugStream
Sets the debug stream for the parser.This method allows setting a
PrintStream
where debug information can be printed during the parsing process. It can be used to redirect debug output to a specific stream, such asSystem.out
or a log file.- Parameters:
ds
- ThePrintStream
to be used for printing debug information.
-
ReInit
Reinitializes the parser's state with a new input stream.This method resets the internal state of the parser so that it can begin reading from a new input stream. It sets the matched position and state counters to zero, assigns the new input stream to the parser, and resets the rounds used for tracking the state of the lexer.
- Parameters:
stream
- The newSimpleCharStream
to be used by the parser.
-
ReInit
Reinitializes the parser's state with a new input stream and switches to the specified lexical state.This method reinitializes the parser by setting a new input stream and also switches the parser to the specified lexical state. It is useful when both the input source and the lexical state need to be reset.
- Parameters:
stream
- The newSimpleCharStream
to be used by the parser.lexState
- The lexical state to switch to after reinitialization.
-
SwitchTo
public void SwitchTo(int lexState) Switches the lexer to the specified lexical state.This method changes the current lexical state of the parser to the specified state. Lexical states are typically used to manage different parsing contexts within the same parser.
- Parameters:
lexState
- The new lexical state to switch to. It must be a valid state between 0 and the maximum defined state.- Throws:
TokenMgrError
- if the specified lexical state is invalid (less than 0 or greater than or equal to 1).
-
getNextToken
-