public abstract class MacroHandlingCPreprocessorBase extends java.lang.Object implements IPreprocessor
Modifier and Type | Field and Description |
---|---|
static java.util.function.Predicate<IToken> |
IS_MACRO_TOKEN
Returns whether the given token is inserted by macro expansion.
|
static java.lang.String |
MACRO_ORIGIN
The origin name used for macro tokens.
|
protected OverlayMacroProvider |
macroProvider
The macro provider used.
|
Modifier | Constructor and Description |
---|---|
protected |
MacroHandlingCPreprocessorBase(IMacroProvider macroProvider)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
handleInclude(java.lang.String uniformPath,
IToken token,
java.util.List<IToken> result,
int inclusionLimit,
java.util.Set<java.lang.String> seenPaths)
Handles the include directive.
|
protected static boolean |
isIfDirective(IToken token)
Returns whether the given token is an if/ifdef/ifndef directive.
|
protected static boolean |
isPragmaDirective(IToken token)
Returns whether the given token is the start of a pragma directive.
|
protected static int |
mergeExpansionIntoTokens(java.util.List<IToken> tokens,
int index,
java.util.List<IToken> expanded,
int tokensConsumed)
Merges the expanded tokens back into the tokens.
|
protected static java.util.List<IToken> |
parseMacroContent(java.lang.String content)
Parses a macor's content.
|
java.util.List<IToken> |
preprocess(java.lang.String uniformPath,
java.util.List<IToken> tokens)
Performs the actual preprocessing of the given tokens.
|
protected java.util.List<IToken> |
preprocess(java.lang.String uniformPath,
java.util.List<IToken> tokens,
int inclusionLimit,
java.util.Set<java.lang.String> seenPaths)
Performs the actual preprocessing of the given tokens.
|
protected abstract void |
processIfDirective(java.util.List<IToken> tokens,
int ifIndex,
RegionSet ignoredRegions)
Processes an if/ifdef/ifndef directive.
|
void |
setUniformPath(java.lang.String uniformPath)
Sets the uniform path which is used in warning messages.
|
public static final java.lang.String MACRO_ORIGIN
public static final java.util.function.Predicate<IToken> IS_MACRO_TOKEN
protected final OverlayMacroProvider macroProvider
protected MacroHandlingCPreprocessorBase(IMacroProvider macroProvider)
public java.util.List<IToken> preprocess(java.lang.String uniformPath, java.util.List<IToken> tokens)
preprocess
in interface IPreprocessor
uniformPath
- may be null if this information is not available.tokens
- A list of tokens that need to be preprocessed. The given list
may get modified.public void setUniformPath(java.lang.String uniformPath)
protected java.util.List<IToken> preprocess(java.lang.String uniformPath, java.util.List<IToken> tokens, int inclusionLimit, java.util.Set<java.lang.String> seenPaths)
uniformPath
- may be null if this information is not available.protected static int mergeExpansionIntoTokens(java.util.List<IToken> tokens, int index, java.util.List<IToken> expanded, int tokensConsumed)
index
might be replaced with
null.protected static boolean isIfDirective(IToken token)
protected static boolean isPragmaDirective(IToken token)
protected abstract void handleInclude(java.lang.String uniformPath, IToken token, java.util.List<IToken> result, int inclusionLimit, java.util.Set<java.lang.String> seenPaths)
uniformPath
- the uniform path of the file with the include.protected abstract void processIfDirective(java.util.List<IToken> tokens, int ifIndex, RegionSet ignoredRegions)
tokens
- the tokens being processed.ifIndex
- the index in the tokens list, where the if directive is found.ignoredRegions
- the regions of indexes to be ignored during parsing.protected static java.util.List<IToken> parseMacroContent(java.lang.String content)