Class Preprocessor
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFeature(@NotNull Feature f) Adds a feature to the feature-set of this Preprocessor.voidaddFeatures(@NotNull Collection<Feature> f) Adds features to the feature-set of this Preprocessor.voidaddFeatures(Feature... f) Adds features 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.voidaddWarning(@NotNull Warning w) Adds a warning to the warning-set of this Preprocessor.voidaddWarnings(@NotNull Collection<Warning> w) Adds warnings to the warning-set of this Preprocessor.voidclose()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.Returns the feature-set for this Preprocessor.Returns the Objective-C frameworks path used by this Preprocessor.@NotNull PreprocessorListenerReturns the PreprocessorListener which handles events for this Preprocessor.@Nullable MacroReturns the named macro.Returns the Map of Macros parsed during the run of this Preprocessor.Returns the user include-path of this Preprocessor.protected SourceReturns the top Source on the input stack.Returns the system include-path of this Preprocessor.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 voidprotected @Nullable Tokenpop_source(boolean linemarker) Pops a Source from the input stack.protected voidprotected voidpush_source(@NotNull Source source, boolean autopop) Pushes a Source onto the input stack.voidsetFrameworksPath(@NotNull List<String> path) Sets the Objective-C frameworks path used by this Preprocessor.voidsetListener(@NotNull PreprocessorListener listener) Sets the PreprocessorListener which handles events for this Preprocessor.voidsetQuoteIncludePath(@NotNull List<String> path) Sets the user include path used by this Preprocessor.voidsetSystemIncludePath(@NotNull List<String> path) Sets the system include path used by this Preprocessor.@NotNull Tokentoken()Returns the next preprocessor token.toString()protected voidHandles a warning.protected voidHandles a warning.
-
Constructor Details
-
Preprocessor
public Preprocessor() -
Preprocessor
-
-
Method Details
-
setListener
Sets the PreprocessorListener which handles events for this Preprocessor.The listener is notified of warnings, errors and source changes, amongst other things.
-
getListener
Returns the PreprocessorListener which handles events for this Preprocessor. -
getFeatures
Returns the feature-set for this Preprocessor.This set may be freely modified by user code.
-
addFeature
Adds a feature to the feature-set of this Preprocessor. -
addFeatures
Adds features to the feature-set of this Preprocessor. -
addFeatures
Adds features 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.
-
addWarning
Adds a warning to the warning-set of this Preprocessor. -
addWarnings
Adds warnings to the warning-set of this Preprocessor. -
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.
-
setQuoteIncludePath
Sets the user include path used by this Preprocessor. -
getQuoteIncludePath
Returns the user include-path of this Preprocessor.This list may be freely modified by user code.
-
setSystemIncludePath
Sets the system include path used by this Preprocessor. -
getSystemIncludePath
Returns the system include-path of this Preprocessor.This list may be freely modified by user code.
-
setFrameworksPath
Sets the Objective-C frameworks path used by this Preprocessor. -
getFrameworksPath
Returns the Objective-C frameworks path used by this Preprocessor.This list may be freely modified by user code.
-
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.- Parameters:
linemarker- TODO: currently ignored, might be a bug?- Throws:
IOException- if an I/O error occurs.- See Also:
-
pop_source
- Throws:
IOException
-
pragma
protected void pragma(@NotNull @NotNull Token name, @NotNull @NotNull List<Token> value) throws IOException, LexerException - Throws:
IOExceptionLexerException
-
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.InternalException- if an unexpected error condition arises.- See Also:
-
toString
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-