Eclipse Platform & Tools v3.6

org.eclipse.cdt.internal.core.parser.scanner
Class CPreprocessor

java.lang.Object
  extended by org.eclipse.cdt.internal.core.parser.scanner.CPreprocessor
All Implemented Interfaces:
IScanner, ILexerLog, IAdaptable

public class CPreprocessor
extends Object
implements ILexerLog, IScanner, IAdaptable

C-Preprocessor providing tokens for the parsers. The class should not be used directly, rather than that you should be using the IScanner interface.

Since:
5.0

Field Summary
protected  org.eclipse.cdt.internal.core.parser.scanner.ScannerContext fCurrentContext
           
static String PROP_VALUE
           
static int tDEFINED
           
static int tEXPANDED_IDENTIFIER
           
static int tMACRO_PARAMETER
           
static int tNOSPACE
           
static int tSCOPE_MARKER
           
static int tSPACE
           
 
Fields inherited from interface org.eclipse.cdt.internal.core.parser.scanner.ILexerLog
NULL
 
Constructor Summary
CPreprocessor(FileContent fileContent, IScannerInfo info, ParserLanguage language, IParserLogService log, IScannerExtensionConfiguration configuration, IncludeFileContentProvider readerFactory)
           
 
Method Summary
 org.eclipse.cdt.internal.core.parser.scanner.PreprocessorMacro addMacroDefinition(char[] key, char[] value)
           
 void cancel()
          Attempts to cancel the scanner.
 Object getAdapter(Class adapter)
          Returns an object which is an instance of the given class associated with this object.
 int getCodeBranchNesting()
          Returns the current nesting in code branches.
protected  String getCurrentFilename()
           
 ILocationResolver getLocationMap()
           
 ILocationResolver getLocationResolver()
          Returns the location resolver associated with this scanner.
 Map<String,IMacroBinding> getMacroDefinitions()
          Returns a map from String to IMacroBinding containing all the definitions that are defined at the current point in the process of scanning.
 void handleComment(boolean isBlockComment, int offset, int endOffset)
          A comment has been detected
 void handleProblem(int id, char[] arg, int offset, int endOffset)
          A problem has been detected
 boolean isContentAssistMode()
           
 boolean isOnTopContext()
          Returns true, whenever we are processing the outermost file of the translation unit.
 IToken nextToken()
          Returns next token for the parser.
 IToken nextTokenRaw()
          Returns next token for the parser.
 void setComputeImageLocations(boolean val)
          Turns on/off creation of image locations.
 void setContentAssistMode(int offset)
          Puts the scanner into content assist mode.
 void setProcessInactiveCode(boolean val)
          Toggles generation of tokens for inactive code branches.
 void setScanComments(boolean val)
           
 void setSplitShiftROperator(boolean val)
          Instructs the scanner to split tokens of kind IToken.tSHIFTR into two tokens of kind IToken.tGT_in_SHIFTR.
 void skipInactiveCode()
          When in inactive code, skips all tokens up to the end of the inactive code section.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_VALUE

public static final String PROP_VALUE
See Also:
Constant Field Values

tDEFINED

public static final int tDEFINED
See Also:
Constant Field Values

tEXPANDED_IDENTIFIER

public static final int tEXPANDED_IDENTIFIER
See Also:
Constant Field Values

tSCOPE_MARKER

public static final int tSCOPE_MARKER
See Also:
Constant Field Values

tSPACE

public static final int tSPACE
See Also:
Constant Field Values

tNOSPACE

public static final int tNOSPACE
See Also:
Constant Field Values

tMACRO_PARAMETER

public static final int tMACRO_PARAMETER
See Also:
Constant Field Values

fCurrentContext

protected org.eclipse.cdt.internal.core.parser.scanner.ScannerContext fCurrentContext
Constructor Detail

CPreprocessor

public CPreprocessor(FileContent fileContent,
                     IScannerInfo info,
                     ParserLanguage language,
                     IParserLogService log,
                     IScannerExtensionConfiguration configuration,
                     IncludeFileContentProvider readerFactory)
Method Detail

setSplitShiftROperator

public void setSplitShiftROperator(boolean val)
Description copied from interface: IScanner
Instructs the scanner to split tokens of kind IToken.tSHIFTR into two tokens of kind IToken.tGT_in_SHIFTR.

Specified by:
setSplitShiftROperator in interface IScanner

setComputeImageLocations

public void setComputeImageLocations(boolean val)
Description copied from interface: IScanner
Turns on/off creation of image locations.

Specified by:
setComputeImageLocations in interface IScanner
See Also:
IASTName.getImageLocation()

setContentAssistMode

public void setContentAssistMode(int offset)
Description copied from interface: IScanner
Puts the scanner into content assist mode.

Specified by:
setContentAssistMode in interface IScanner

isContentAssistMode

public boolean isContentAssistMode()

setProcessInactiveCode

public void setProcessInactiveCode(boolean val)
Description copied from interface: IScanner
Toggles generation of tokens for inactive code branches. When turned on, each inactive code branch is preceded by a token of kind IToken.tINACTIVE_CODE_START and succeeded by one of kind IToken.tINACTIVE_CODE_END.

Specified by:
setProcessInactiveCode in interface IScanner

setScanComments

public void setScanComments(boolean val)
Specified by:
setScanComments in interface IScanner

getLocationResolver

public ILocationResolver getLocationResolver()
Description copied from interface: IScanner
Returns the location resolver associated with this scanner.

Specified by:
getLocationResolver in interface IScanner

getCurrentFilename

protected String getCurrentFilename()

addMacroDefinition

public org.eclipse.cdt.internal.core.parser.scanner.PreprocessorMacro addMacroDefinition(char[] key,
                                                                                         char[] value)

getMacroDefinitions

public Map<String,IMacroBinding> getMacroDefinitions()
Description copied from interface: IScanner
Returns a map from String to IMacroBinding containing all the definitions that are defined at the current point in the process of scanning.

Specified by:
getMacroDefinitions in interface IScanner

isOnTopContext

public boolean isOnTopContext()
Description copied from interface: IScanner
Returns true, whenever we are processing the outermost file of the translation unit.

Specified by:
isOnTopContext in interface IScanner

cancel

public void cancel()
Description copied from interface: IScanner
Attempts to cancel the scanner.

Specified by:
cancel in interface IScanner

nextTokenRaw

public IToken nextTokenRaw()
                    throws OffsetLimitReachedException
Returns next token for the parser. String literals are not concatenated. When the end is reached tokens with type IToken.tEND_OF_INPUT.

Throws:
OffsetLimitReachedException - see Lexer.

nextToken

public IToken nextToken()
                 throws EndOfFileException
Returns next token for the parser. String literals are concatenated.

Specified by:
nextToken in interface IScanner
Throws:
EndOfFileException - when the end of the translation unit has been reached.
OffsetLimitReachedException - see Lexer.

skipInactiveCode

public void skipInactiveCode()
                      throws OffsetLimitReachedException
Description copied from interface: IScanner
When in inactive code, skips all tokens up to the end of the inactive code section.

Note, token after calling this method may be another token of type IToken.tINACTIVE_CODE_START.

Specified by:
skipInactiveCode in interface IScanner
Throws:
OffsetLimitReachedException

getCodeBranchNesting

public int getCodeBranchNesting()
Description copied from interface: IScanner
Returns the current nesting in code branches.

Specified by:
getCodeBranchNesting in interface IScanner
See Also:
IInactiveCodeToken.getOldNesting(), IInactiveCodeToken.getNewNesting()

toString

public String toString()
Overrides:
toString in class Object

getLocationMap

public ILocationResolver getLocationMap()

handleComment

public void handleComment(boolean isBlockComment,
                          int offset,
                          int endOffset)
Description copied from interface: ILexerLog
A comment has been detected

Specified by:
handleComment in interface ILexerLog
Parameters:
isBlockComment - true for block-comments, false for line-comments.
offset - the offset where the comment starts
endOffset - the offset where the comment ends

handleProblem

public void handleProblem(int id,
                          char[] arg,
                          int offset,
                          int endOffset)
Description copied from interface: ILexerLog
A problem has been detected

Specified by:
handleProblem in interface ILexerLog
Parameters:
id - id as defined in IProblem
arg - additional info as required for IProblem.
offset - The offset of the problem in the source of the lexer.
endOffset - end offset of the problem in the source of the lexer.

getAdapter

public Object getAdapter(Class adapter)
Description copied from interface: IAdaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface IAdaptable
Parameters:
adapter - the adapter class to look up
Returns:
a object castable to the given class, or null if this object does not have an adapter for the given class

Eclipse Platform & Tools v3.6