public class Preprocessor extends java.lang.Object implements java.io.Closeable
| Constructor and Description |
|---|
Preprocessor() |
Preprocessor(java.io.File file)
Equivalent to
'new Preprocessor(new
FileLexerSource(file))' |
Preprocessor(Source initial) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFeature(Feature f)
Adds a feature to the feature-set of this Preprocessor.
|
void |
addFeatures(java.util.Collection<Feature> f)
Adds features to the feature-set of this Preprocessor.
|
void |
addFeatures(Feature... f)
Adds features to the feature-set of this Preprocessor.
|
void |
addInput(java.io.File file)
Adds input for the Preprocessor.
|
void |
addInput(Source source)
Adds input for the Preprocessor.
|
void |
addMacro(Macro m)
Adds a Macro to this Preprocessor.
|
void |
addMacro(java.lang.String name)
Defines the given name as a macro, with the value
1. |
void |
addMacro(java.lang.String name,
java.lang.String value)
Defines the given name as a macro.
|
void |
addWarning(Warning w)
Adds a warning to the warning-set of this Preprocessor.
|
void |
addWarnings(java.util.Collection<Warning> w)
Adds warnings to the warning-set of this Preprocessor.
|
void |
close() |
protected void |
error(int line,
int column,
java.lang.String msg)
Handles an error.
|
protected void |
error(Token tok,
java.lang.String msg)
Handles an error.
|
boolean |
getFeature(Feature f)
Returns true if the given feature is in
the feature-set of this Preprocessor.
|
java.util.Set<Feature> |
getFeatures()
Returns the feature-set for this Preprocessor.
|
VirtualFileSystem |
getFileSystem()
Returns the VirtualFileSystem used by this Preprocessor.
|
java.util.List<java.lang.String> |
getFrameworksPath()
Returns the Objective-C frameworks path used by this
Preprocessor.
|
java.util.List<? extends VirtualFile> |
getIncludes()
Returns the list of
VirtualFiles which have been
included by this Preprocessor. |
PreprocessorListener |
getListener()
Returns the PreprocessorListener which handles events for
this Preprocessor.
|
Macro |
getMacro(java.lang.String name)
Returns the named macro.
|
java.util.Map<java.lang.String,Macro> |
getMacros()
Returns the Map of Macros parsed during the run of this
Preprocessor.
|
java.util.List<java.lang.String> |
getQuoteIncludePath()
Returns the user include-path of this Preprocessor.
|
protected Source |
getSource()
Returns the top Source on the input stack.
|
java.util.List<java.lang.String> |
getSystemIncludePath()
Returns the system include-path of this Preprocessor.
|
boolean |
getWarning(Warning w)
Returns true if the given warning is in
the warning-set of this Preprocessor.
|
java.util.Set<Warning> |
getWarnings()
Returns the warning-set for this Preprocessor.
|
protected boolean |
include(java.lang.Iterable<java.lang.String> path,
java.lang.String name)
Attempts to include a file from an include path, by name.
|
protected boolean |
include(VirtualFile file)
Attempts to include the given file.
|
protected void |
pop_source() |
protected Token |
pop_source(boolean linemarker)
Pops a Source from the input stack.
|
protected void |
pragma_once(Token name) |
protected void |
pragma(Token name,
java.util.List<Token> value) |
protected void |
push_source(Source source,
boolean autopop)
Pushes a Source onto the input stack.
|
void |
setFileSystem(VirtualFileSystem filesystem)
Sets the VirtualFileSystem used by this Preprocessor.
|
void |
setFrameworksPath(java.util.List<java.lang.String> path)
Sets the Objective-C frameworks path used by this Preprocessor.
|
void |
setListener(PreprocessorListener listener)
Sets the PreprocessorListener which handles events for
this Preprocessor.
|
void |
setQuoteIncludePath(java.util.List<java.lang.String> path)
Sets the user include path used by this Preprocessor.
|
void |
setSystemIncludePath(java.util.List<java.lang.String> path)
Sets the system include path used by this Preprocessor.
|
Token |
token()
Returns the next preprocessor token.
|
java.lang.String |
toString() |
protected void |
warning(int line,
int column,
java.lang.String msg)
Handles a warning.
|
protected void |
warning(Token tok,
java.lang.String msg)
Handles a warning.
|
public Preprocessor()
public Preprocessor(@Nonnull Source initial)
public Preprocessor(@Nonnull java.io.File file) throws java.io.IOException
FileLexerSource(file))'java.io.IOExceptionpublic void setFileSystem(@Nonnull VirtualFileSystem filesystem)
@Nonnull public VirtualFileSystem getFileSystem()
public void setListener(@Nonnull PreprocessorListener listener)
@Nonnull public PreprocessorListener getListener()
@Nonnull public java.util.Set<Feature> getFeatures()
public void addFeature(@Nonnull Feature f)
public void addFeatures(@Nonnull java.util.Collection<Feature> f)
public void addFeatures(Feature... f)
public boolean getFeature(@Nonnull Feature f)
@Nonnull public java.util.Set<Warning> getWarnings()
public void addWarning(@Nonnull Warning w)
public void addWarnings(@Nonnull java.util.Collection<Warning> w)
public boolean getWarning(@Nonnull Warning w)
public void addInput(@Nonnull Source source)
public void addInput(@Nonnull java.io.File file) throws java.io.IOException
java.io.IOExceptionaddInput(Source)protected void error(int line, int column, @Nonnull java.lang.String msg) throws LexerException
LexerExceptionprotected void error(@Nonnull Token tok, @Nonnull java.lang.String msg) throws LexerException
LexerExceptionerror(int, int, String)protected void warning(int line, int column, @Nonnull java.lang.String msg) throws LexerException
LexerExceptionprotected void warning(@Nonnull Token tok, @Nonnull java.lang.String msg) throws LexerException
LexerExceptionwarning(int, int, String)public void addMacro(@Nonnull Macro m) throws LexerException
Macro object encapsulates both the name
and the expansion.LexerException - if the definition fails or is otherwise illegal.public void addMacro(@Nonnull java.lang.String name, @Nonnull java.lang.String value) throws LexerException
LexerException - if the definition fails or is otherwise illegal.public void addMacro(@Nonnull java.lang.String name) throws LexerException
1.
This is a convnience method, and is equivalent to
addMacro(name, "1").LexerException - if the definition fails or is otherwise illegal.public void setQuoteIncludePath(@Nonnull java.util.List<java.lang.String> path)
@Nonnull public java.util.List<java.lang.String> getQuoteIncludePath()
public void setSystemIncludePath(@Nonnull java.util.List<java.lang.String> path)
@Nonnull public java.util.List<java.lang.String> getSystemIncludePath()
public void setFrameworksPath(@Nonnull java.util.List<java.lang.String> path)
@Nonnull public java.util.List<java.lang.String> getFrameworksPath()
@Nonnull public java.util.Map<java.lang.String,Macro> getMacros()
Map of macros currently defined.@CheckForNull public Macro getMacro(@Nonnull java.lang.String name)
@Nonnull public java.util.List<? extends VirtualFile> getIncludes()
VirtualFiles which have been
included by this Preprocessor.
This does not include any Source provided to the constructor
or addInput(java.io.File) or addInput(Source).protected Source getSource()
Source,
push_source(Source,boolean),
pop_source()protected void push_source(@Nonnull Source source, boolean autopop)
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.getSource(),
pop_source()@CheckForNull protected Token pop_source(boolean linemarker) throws java.io.IOException
linemarker - TODO: currently ignored, might be a bug?java.io.IOException - if an I/O error occurs.getSource(),
push_source(Source,boolean)protected void pop_source() throws java.io.IOException
java.io.IOExceptionprotected boolean include(@Nonnull VirtualFile file) throws java.io.IOException
file - The VirtualFile to attempt to include.java.io.IOException - if an I/O error occurs.protected boolean include(@Nonnull java.lang.Iterable<java.lang.String> path, @Nonnull java.lang.String name) throws java.io.IOException
path - The list of virtual directories to search for the given name.name - The name of the file to attempt to include.java.io.IOException - if an I/O error occurs.protected void pragma_once(@Nonnull Token name) throws java.io.IOException, LexerException
java.io.IOExceptionLexerExceptionprotected void pragma(@Nonnull Token name, @Nonnull java.util.List<Token> value) throws java.io.IOException, LexerException
java.io.IOExceptionLexerException@Nonnull public Token token() throws java.io.IOException, LexerException
java.io.IOException - if an I/O error occurs.LexerException - if a preprocessing error occurs.InternalException - if an unexpected error condition arises.Tokenpublic java.lang.String toString()
toString in class java.lang.Objectpublic void close() throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException