Package com.sonar.sslr.api
Class Preprocessor2
java.lang.Object
com.sonar.sslr.api.Preprocessor2
- Direct Known Subclasses:
CobolPreprocessor
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidendLexing(LexerOutput output) Method calls after having lexed a source code.abstract booleanprocess(Token token, LexerOutput output) This method is called just before adding a new Token to the LexerOutput.voidMethod calls before starting lexing the source code.
-
Constructor Details
-
Preprocessor2
public Preprocessor2()
-
-
Method Details
-
process
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 preprocessoutput- 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
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.
-