FileIncludeStack¶
This module represents a stack of file includes as used by the
PpLexer.PpLexer
-
exception
cpip.core.FileIncludeStack.
ExceptionFileIncludeStack
¶ Exception for FileIncludeStack object.
-
class
cpip.core.FileIncludeStack.
FileInclude
(theFpo, theDiag)¶ Represents a single TU fragment with a PpTokeniser and a token counter.
-
__init__
(theFpo, theDiag)¶ Constructor.
Parameters: - theFpo (
cpip.core.IncludeHandler.FilePathOrigin([_io.StringIO, str, NoneType, str]), cpip.core.IncludeHandler.FilePathOrigin([_io.TextIOWrapper, str, str, str])
) – A FilePathOrigin object that identifies the file. - theDiag (
cpip.core.CppDiagnostic.PreprocessDiagnosticStd
) – A CppDiagnostic object to give to the PpTokeniser.
Returns: NoneType
- theFpo (
-
__weakref__
¶ list of weak references to the object (if defined)
-
tokenCountInc
(tok, isUnCond, num=1)¶ Increment the token counter.
Parameters: - tok (
cpip.core.PpToken.PpToken
) – Token. - isUnCond (
bool
) – Unconditional flag. - num (
int
) – Increment, default 1.
Returns: NoneType
- tok (
-
tokenCounterAdd
(theC)¶ Add a token counter to my token counter (used when a macro is declared).
Parameters: theC ( cpip.core.PpTokenCount.PpTokenCount
) – Token counter.Returns: NoneType
-
-
class
cpip.core.FileIncludeStack.
FileIncludeStack
(theDiagnostic)¶ This maintains information about the stack of file includes. This holds several stacks (or representations of them):
- self._ppts
- A stack of
PpTokeniser.PpTokeniser
objects. - self._figr
- A
FileIncludeGraph.FileIncludeGraphRoot
for tracking the#include
graph. - self._fns
- A stack of file IDs as strings (e.g. the file path).
- self._tcs
- A
PpTokenCount.PpTokenCountStack
object for counting tokens.
-
__init__
(theDiagnostic)¶ Constructor, takes a CppDiagnostic object to give to the PpTokeniser.
Parameters: theDiagnostic ( cpip.core.CppDiagnostic.PreprocessDiagnosticStd
) – The diagnostic for emitting messages.Returns: NoneType
-
__weakref__
¶ list of weak references to the object (if defined)
-
currentFile
¶ Returns the file ID from the top of the stack.
Returns: str
– File ID.
-
depth
¶ Returns the current include depth as an integer.
Returns: int
– Depth.
-
fileIncludeGraphRoot
¶ The
FileIncludeGraph.FileIncludeGraphRoot
object.Returns: cpip.core.FileIncludeGraph.FileIncludeGraphRoot
– The include graph root.
-
fileLineCol
¶ Return an instance of FileLineCol from the current physical line column.
Returns: cpip.core.FileLocation.FileLineCol
– File location.
-
fileStack
¶ Returns a copy of the stack of file IDs.
Returns: list([str])
– File IDs.
-
finalise
()¶ Finalisation, may raise an ExceptionFileIncludeStack.
Returns: NoneType
-
includeFinish
()¶ End an
#include
file, returns the file ID that has been finished.Returns: str
– File ID such as a path.
-
includeStart
(theFpo, theLineNum, isUncond, condStr, incLogic)¶ Start an
#include
file.Parameters: - theFpo (
cpip.core.IncludeHandler.FilePathOrigin([_io.StringIO, str, NoneType, str]), cpip.core.IncludeHandler.FilePathOrigin([_io.TextIOWrapper, str, str, str])
) – AFileLocation.FilePathOrigin
object that identifies the file. - theLineNum (
NoneType, int
) – The integer line number of the file that includes (None if Root). - isUncond (
bool
) – A boolean that is the conditional compilation state. - condStr (
str
) – A string of the conditional compilation stack. - incLogic (
list([]), list([str])
) – A string that describes the find include logic.
Returns: NoneType
- theFpo (
-
ppt
¶ Returns the PpTokeniser from the top of the stack.
Returns: cpip.core.PpTokeniser.PpTokeniser
– The tokeniser.
-
tokenCountInc
(tok, isUnCond, num=1)¶ Increment the token counter.
Parameters: - tok (
cpip.core.PpToken.PpToken
) – The token. - isUnCond (
bool
) – Is unconditionally compiled. - num (
int
) – Increment, default 1.
Returns: NoneType
- tok (
-
tokenCounter
()¶ Returns the Token Counter object at the tip of the stack.
-
tokenCounterAdd
(theC)¶ Add a token counter to my token counter (used when a macro is declared).
Parameters: theC ( cpip.core.PpTokenCount.PpTokenCount
) – The token counter.Returns: NoneType