Class Preprocessor
java.lang.Object
io.github.douira.glsl_preprocessor.Preprocessor
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a feature to the feature-set of this Preprocessor.voidaddFeatures(Feature... f) Adds features to the feature-set of this Preprocessor.voidAdds 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.voidAdds a warning to the warning-set of this Preprocessor.voidAdds warnings to the warning-set of this Preprocessor.voidclose()protected voidHandles an error.protected voidHandles an error.booleanReturns true if the given feature is in the feature-set of this Preprocessor.Returns the feature-set for this Preprocessor.Returns the VirtualFileSystem used by this Preprocessor.List<? extends VirtualFile>Returns the list ofVirtualFileswhich have been included by this Preprocessor.Returns the PreprocessorListener which handles events for this Preprocessor.Returns the named macro.Returns the Map of Macros parsed during the run of this Preprocessor.protected SourceReturns the top Source on the input stack.booleanReturns true if the given warning is in the warning-set of this Preprocessor.Returns the warning-set for this Preprocessor.protected booleaninclude(VirtualFile file) Attempts to include the given file.protected booleanAttempts to include a file from an include path, by name.protected voidprotected Tokenpop_source(boolean linemarker) Pops a Source from the input stack.protected voidprotected voidpragma_once(Token name) print()voidprintTo(StringBuilder builder) protected voidpush_source(Source source, boolean autopop) Pushes a Source onto the input stack.voidsetFileSystem(VirtualFileSystem filesystem) Sets the VirtualFileSystem used by this Preprocessor.voidsetListener(PreprocessorListener listener) Sets the PreprocessorListener which handles events for this Preprocessor.token()Returns the next preprocessor token.toString()protected voidHandles a warning.protected voidHandles a warning.
-
Constructor Details
-
Preprocessor
public Preprocessor() -
Preprocessor
-
Preprocessor
-
Preprocessor
-
-
Method Details
-
setFileSystem
Sets the VirtualFileSystem used by this Preprocessor. -
getFileSystem
Returns the VirtualFileSystem used by this Preprocessor. -
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. -
error
Handles an error. If a PreprocessorListener is installed, it receives the error. Otherwise, an exception is thrown.- See Also:
-
warning
Handles a warning. If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown. -
warning
Handles a warning. If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown.- See Also:
-
addMacro
Adds a Macro to this Preprocessor. The givenMacroobject encapsulates both the name and the expansion.- Throws:
LexerException- if the definition fails or is otherwise illegal.
-
addMacro
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 convenience method, and is equivalent toaddMacro(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.
-
getIncludes
Returns the list ofVirtualFileswhich have been included by this Preprocessor. This does not include anySourceprovided to the constructor oraddInput(Source). -
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?- See Also:
-
pop_source
protected void pop_source() -
include
Attempts to include the given file. User code may override this method to implement a virtual file system.- Parameters:
file- The VirtualFile to attempt to include.- Returns:
- true if the file was successfully included, false otherwise.
-
include
Attempts to include a file from an include path, by name.- Parameters:
path- The list of virtual directories to search for the given name.name- The name of the file to attempt to include.- Returns:
- true if the file was successfully included, false otherwise.
-
pragma_once
-
pragma
-
token
Returns the next preprocessor token.- Returns:
- The next fully preprocessed token.
- See Also:
-
printTo
-
print
-
printToString
-
toString
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-