Class Preprocessor
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFeature
(@NotNull Feature f) Adds a feature to the feature-set of this Preprocessor.void
addFeatures
(Feature... f) Adds features to the feature-set of this Preprocessor.void
addFeatures
(@NotNull Collection<Feature> f) Adds features to the feature-set of this Preprocessor.void
Adds input for the Preprocessor.void
Adds a Macro to this Preprocessor.void
Defines the given name as a macro, with the value1
.void
Defines the given name as a macro.void
addWarning
(@NotNull Warning w) Adds a warning to the warning-set of this Preprocessor.void
addWarnings
(@NotNull Collection<Warning> w) Adds warnings to the warning-set of this Preprocessor.void
close()
protected void
Handles an error.protected void
Handles an error.boolean
getFeature
(@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 PreprocessorListener
Returns the PreprocessorListener which handles events for this Preprocessor.@Nullable Macro
Returns the named macro.Returns the Map of Macros parsed during the run of this Preprocessor.Returns the user include-path of this Preprocessor.protected Source
Returns the top Source on the input stack.Returns the system include-path of this Preprocessor.boolean
getWarning
(@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 void
protected @Nullable Token
pop_source
(boolean linemarker) Pops a Source from the input stack.protected void
protected void
push_source
(@NotNull Source source, boolean autopop) Pushes a Source onto the input stack.void
setFrameworksPath
(@NotNull List<String> path) Sets the Objective-C frameworks path used by this Preprocessor.void
setListener
(@NotNull PreprocessorListener listener) Sets the PreprocessorListener which handles events for this Preprocessor.void
setQuoteIncludePath
(@NotNull List<String> path) Sets the user include path used by this Preprocessor.void
setSystemIncludePath
(@NotNull List<String> path) Sets the system include path used by this Preprocessor.@NotNull Token
token()
Returns the next preprocessor token.toString()
protected void
Handles a warning.protected void
Handles 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
Macro
object 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
Map
of 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:
IOException
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.InternalException
- if an unexpected error condition arises.- See Also:
-
toString
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-