Class Preprocessor2

  • Direct Known Subclasses:
    CobolPreprocessor

    public abstract class Preprocessor2
    extends Object
    A Preprocessor can be used to modify the content of the LexerOuput before launching the parser. A proprocessor can be used for instance to replace a token or a list of tokens by another token or list of tokens.
    • Constructor Detail

      • Preprocessor2

        public Preprocessor2()
    • Method Detail

      • process

        public abstract boolean process​(Token token,
                                        LexerOutput output)
        This method is called just before adding a new Token to the LexerOutput. The Preprocessor is able to intercept this token and do what ever it wants with it.
        Parameters:
        token - the token to preprocess
        output - the lexer output that can be used to inject any tokens.
        Returns:
        false if that token hasn't been pre-processed and true otherwise. If the method returns true, no other preprocessing operations will be done on this token and this token won't be added to the LexerOutput
      • endLexing

        public void endLexing​(LexerOutput output)
        Method calls after having lexed a source code. Some additional operations can be done by the Preprocessor on the LexerOuput if required.
      • startLexing

        public void startLexing()
        Method calls before starting lexing the source code. This method can be overridden to initialize a state for instance.