public class Preprocessor extends Object implements Closeable
Constructor and Description |
---|
Preprocessor() |
Preprocessor(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(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(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(String name)
Defines the given name as a macro, with the value
1 . |
void |
addMacro(String name,
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(Collection<Warning> w)
Adds warnings to the warning-set of this Preprocessor.
|
void |
close() |
protected void |
error(int line,
int column,
String msg)
Handles an error.
|
protected void |
error(Token tok,
String msg)
Handles an error.
|
boolean |
getFeature(Feature f)
Returns true if the given feature is in
the feature-set of this Preprocessor.
|
Set<Feature> |
getFeatures()
Returns the feature-set for this Preprocessor.
|
VirtualFileSystem |
getFileSystem()
Returns the VirtualFileSystem used by this Preprocessor.
|
List<String> |
getFrameworksPath()
Returns the Objective-C frameworks path used by this
Preprocessor.
|
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(String name)
Returns the named macro.
|
Map<String,Macro> |
getMacros()
Returns the Map of Macros parsed during the run of this
Preprocessor.
|
List<Macro> |
getMacros(boolean expand)
Returns a list of
Macro s. |
List<String> |
getQuoteIncludePath()
Returns the user include-path of this Preprocessor.
|
Source |
getSource()
Returns the top Source on the input stack.
|
List<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.
|
Set<Warning> |
getWarnings()
Returns the warning-set for this Preprocessor.
|
protected boolean |
include(Iterable<String> path,
String name)
Includes 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,
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(List<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(List<String> path)
Sets the user include path used by this Preprocessor.
|
void |
setSystemIncludePath(List<String> path)
Sets the system include path used by this Preprocessor.
|
Token |
token()
Returns the next preprocessor token.
|
String |
toString() |
protected void |
warning(int line,
int column,
String msg)
Handles a warning.
|
protected void |
warning(Token tok,
String msg)
Handles a warning.
|
public Preprocessor()
public Preprocessor(Source initial)
public Preprocessor(File file) throws IOException
FileLexerSource
(file))'IOException
public void setFileSystem(VirtualFileSystem filesystem)
public VirtualFileSystem getFileSystem()
public void setListener(PreprocessorListener listener)
public PreprocessorListener getListener()
public Set<Feature> getFeatures()
public void addFeature(Feature f)
public void addFeatures(Collection<Feature> f)
public void addFeatures(Feature... f)
public boolean getFeature(Feature f)
public Set<Warning> getWarnings()
public void addWarning(Warning w)
public void addWarnings(Collection<Warning> w)
public boolean getWarning(Warning w)
public void addInput(Source source)
public void addInput(File file) throws IOException
IOException
addInput(Source)
protected void error(int line, int column, String msg) throws LexerException
LexerException
protected void error(Token tok, String msg) throws LexerException
LexerException
error(int, int, String)
protected void warning(int line, int column, String msg) throws LexerException
LexerException
protected void warning(Token tok, String msg) throws LexerException
LexerException
warning(int, int, String)
public void addMacro(Macro m) throws LexerException, IOException
Macro
object encapsulates both the name
and the expansion.IOException
LexerException
public void addMacro(String name, String value) throws LexerException
LexerException
public void addMacro(String name) throws LexerException
1
.
This is a convnience method, and is equivalent to
addMacro(name, "1")
.LexerException
public void setQuoteIncludePath(List<String> path)
public List<String> getQuoteIncludePath()
public void setSystemIncludePath(List<String> path)
public List<String> getSystemIncludePath()
public void setFrameworksPath(List<String> path)
public List<String> getFrameworksPath()
public Map<String,Macro> getMacros()
public List<Macro> getMacros(boolean expand) throws IOException, LexerException
expand
- if true
and if macro is not function-like
,
i.e. a constant, the returned macro will be expanded.IOException
LexerException
public Macro getMacro(String name)
public 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)
.public Source getSource()
Source
,
push_source(Source,boolean)
,
pop_source()
protected void push_source(Source source, boolean autopop)
getSource()
,
pop_source()
protected Token pop_source(boolean linemarker) throws IOException
IOException
getSource()
,
push_source(Source,boolean)
protected void pop_source() throws IOException
IOException
protected boolean include(VirtualFile file) throws IOException, LexerException
IOException
LexerException
protected boolean include(Iterable<String> path, String name) throws IOException, LexerException
IOException
LexerException
protected void pragma_once(Token name) throws IOException, LexerException
IOException
LexerException
protected void pragma(Token name, List<Token> value) throws IOException, LexerException
IOException
LexerException
public Token token() throws IOException, LexerException
LexerException
- if a preprocessing error occurs.InternalException
- if an unexpected error condition arises.IOException
Token
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException