Class Preprocessor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFeature(@NotNull Feature f) Adds a feature to the feature-set of this Preprocessor.voidAdds input for the Preprocessor.voidAdds a Macro to this Preprocessor.voidDefines the given name as a macro, with the value1.voidDefines the given name as a macro.protected voidHandles an error.protected voidHandles an error.booleangetFeature(@NotNull Feature f) Returns true if the given feature is in the feature-set of this Preprocessor.@Nullable MacroReturns the named macro.Returns the Map of Macros parsed during the run of this Preprocessor.protected SourceReturns the top Source on the input stack.booleangetWarning(@NotNull Warning w) Returns true if the given warning is in the warning-set of this Preprocessor.Returns the warning-set for this Preprocessor.protected @Nullable TokenPops a Source from the input stack.protected voidprotected voidpush_source(@NotNull Source source, boolean autopop) Pushes a Source onto the input stack.@NotNull Tokentoken()Returns the next preprocessor token.toString()protected voidHandles a warning.protected voidHandles a warning.
-
Constructor Details
-
Preprocessor
public Preprocessor()
-
-
Method Details
-
addFeature
Adds a feature to the feature-set of this Preprocessor. -
getFeature
Returns true if the given feature is in the feature-set of this Preprocessor. -
getWarnings
Returns the warning-set for this Preprocessor.This set may be freely modified by user code.
-
getWarning
Returns true if the given warning is in the warning-set of this Preprocessor. -
addInput
Adds input for the Preprocessor.Inputs are processed in the order in which they are added.
-
error
Handles an error.If a PreprocessorListener is installed, it receives the error. Otherwise, an exception is thrown.
- Throws:
LexerException
-
error
protected void error(@NotNull @NotNull Token tok, @NotNull @NotNull String msg) throws LexerException Handles an error.If a PreprocessorListener is installed, it receives the error. Otherwise, an exception is thrown.
- Throws:
LexerException- See Also:
-
warning
Handles a warning.If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown.
- Throws:
LexerException
-
warning
protected void warning(@NotNull @NotNull Token tok, @NotNull @NotNull String msg) throws LexerException Handles a warning.If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown.
- Throws:
LexerException- See Also:
-
addMacro
Adds a Macro to this Preprocessor.The given
Macroobject encapsulates both the name and the expansion.- Throws:
LexerException- if the definition fails or is otherwise illegal.
-
addMacro
public void addMacro(@NotNull @NotNull String name, @NotNull @NotNull String value) throws LexerException Defines the given name as a macro.The String value is lexed into a token stream, which is used as the macro expansion.
- Throws:
LexerException- if the definition fails or is otherwise illegal.
-
addMacro
Defines the given name as a macro, with the value1.This is a convnience method, and is equivalent to
addMacro(name, "1").- Throws:
LexerException- if the definition fails or is otherwise illegal.
-
getMacros
Returns the Map of Macros parsed during the run of this Preprocessor.- Returns:
- The
Mapof macros currently defined.
-
getMacro
Returns the named macro.While you can modify the returned object, unexpected things might happen if you do.
- Returns:
- the Macro object, or null if not found.
-
getSource
Returns the top Source on the input stack.- Returns:
- the top Source on the input stack.
- See Also:
-
push_source
Pushes a Source onto the input stack.- Parameters:
source- the new Source to push onto the top of the input stack.autopop- if true, the Source is automatically removed from the input stack at EOF.- See Also:
-
pop_source
Pops a Source from the input stack.- See Also:
-
pragma
- Throws:
LexerException
-
token
Returns the next preprocessor token.- Returns:
- The next fully preprocessed token.
- Throws:
IOException- if an I/O error occurs.LexerException- if a preprocessing error occurs.AssertionError- if an unexpected error condition arises.- See Also:
-
toString
-