Generates tokens from a C or C++ translation unit.
TODO: Fix accidental token pasting.
TODO: Preprocessor statements in arguments of function like macros. Sect. 3.9 of cpp.pdf and existing MacroEnv tests.
Exception when handling PpLexer object.
Exception when two generators are created then the internal state will become inconsistent.
Exception when finding issues with the call stack or nested includes.
Exception when sys.getrecursionlimit() is too small.
Exception when handling a conditional token generation level.
Exception when loading predefined macro definitions.
Exception when nested #include limit exceeded.
Exception when can not find file.
Exception when loading pre-include files.
Exception when loading a pre-include file that has no current place (e.g. a StringIO object) and the pre-include then has an #include statement.
Exception when loading predefined macro definitions.
Allowable preprocessing directives
Create a translation unit tokeniser that applies ISO/IEC 9899:1999(E) Section 6 and ISO/IEC 14882:1998(E) section 16.
TODO: Set flags here rather than supplying them to a generator? This would make the API simply the ctor and ppTokens/next(). Flags would be:
incWs - Include whitespace tokens.
condLevel - (0, 1, 2) thus:
not have any information about conditionally included files.
conditionally included files. The fileIncludeGraphRoot will have a reference to a conditionally included file but not that included file’s includes.
included files. The fileIncludeGraphRoot will have all the information about conditionally included files recursively.
Each include The call stack depth, D = A + B + C*L Where L is the number of levels of nested includes and A is the call stack A above:
B above:
C above:
Conditianlity settings for token generation
Conditionality level (0, 1, 2)
The maximum value of nested #include’s
Returns the current column number as an integer during processing.
The conditional compilation graph as a CppCond.CppCondGraph object.
The conditional state as (boolean, string).
Returns the file ID on the top of the file stack.
Returns a string representing the currently defined macros.
Returns the FileIncludeGraphRoot object.
Returns a FileLineCol object or None
Returns the current file name during processing.
Returns the file stack.
Finalisation, may raise any Exception.
Returns the integer depth of the include stack.
Returns the current line number as an integer during processing or None.
The current Macro environment as a MacroEnv object. Caution: Write to this at your own risk. Your write might be ignored or cause undefined behaviour.
A generator for providing PpToken.PpTokens to section 16 of ISO/IEC 14882:1998(E).
incWs - if True than whitespace tokens are included (i.e. tok.isWs() == True).
minWs - if True then whitespace runs will be minimised to a single space or, if newline is in the whitespce run, a single newline
condLevel - if True then conditionally compiled tokens will be yielded and they will have have tok.isCond == True. The fileIncludeGraphRoot will be marked up with the appropriate conditionality. Levels are:
0: No conditionally compiled tokens. The fileIncludeGraphRoot will
not have any information about conditionally included files.
1: Conditionally compiled tokens are generated but not from
conditionally included files. The fileIncludeGraphRoot will have
a reference to a conditionally included file but not that
included file's includes.
2: Conditionally compiled tokens including tokens from conditionally
included files. The fileIncludeGraphRoot will have all the
information about conditionally included files recursively.
(see _cppInclude where we check if self._condStack.isTrue():).
Returns the user supplied ID of the translation unit.
Used when file objects have no name