Class POParserTokenManager

java.lang.Object
org.tweetyproject.preferences.io.POParserTokenManager
All Implemented Interfaces:
POParserConstants

public class POParserTokenManager extends Object implements POParserConstants
Token Manager.
  • Field Details

    • debugStream

      public PrintStream debugStream
      Debug output.
    • jjstrLiteralImages

      public static final String[] jjstrLiteralImages
      Token literal values.
    • lexStateNames

      public static final String[] lexStateNames
      Lexer state names.
  • Constructor Details

    • POParserTokenManager

      public POParserTokenManager(SimpleCharStream stream)
      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

      public POParserTokenManager(SimpleCharStream stream, int lexState)
      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

      public void setDebugStream(PrintStream ds)
      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 as System.out or a log file.

      Parameters:
      ds - The PrintStream to be used for printing debug information.
    • ReInit

      public void ReInit(SimpleCharStream stream)
      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 new SimpleCharStream to be used by the parser.
    • ReInit

      public void ReInit(SimpleCharStream stream, int lexState)
      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 new SimpleCharStream 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

      public Token getNextToken()
      Return the next token
      Returns:
      the next token