paulross / cpip Goto Github PK
View Code? Open in Web Editor NEWCPIP - a C/C++ preprocessor implemented in Python.
License: GNU General Public License v2.0
CPIP - a C/C++ preprocessor implemented in Python.
License: GNU General Public License v2.0
When I try to use cpip with Python 3.7 I run into some problems:
the verbose flag on namedtuple has been removed. this was easy to patch into your code. Once I passed this hurdle I get this callstack, which I can't understand:
1> File "C:\src\honey\tools\cpip\core\PpLexer.py", line 480, in ppTokens
1> for aTok in self._genPreIncludeTokens():
1> File "C:\src\honey\tools\cpip\core\PpLexer.py", line 375, in _genPreIncludeTokens
1> for aTok in self._genPpTokensRecursive(myGen):
1>RuntimeError: generator raised StopIteration
This is for the latest commit (hash: 10e6959). I had to use the master as the last official release 0.9.7 does not contain the bugfix for file/line related to the missing currentFileIsSystemFile property of FileIncludeStack.
For some reason I am not able to pass Defines to the PpLexer using the preDefines.
Like in the Demo, how do i pass AUSTRALIAN & LANG_SUPPORT for example ?
myLex = PpLexer.PpLexer(cpp_file, handlerObj)
We currently support the L
e.g. L'A'
prefix for character-literal (ISO/IEC 14882:1998(E) 2.13.2 Character literals [lex.ccon]). However we do not support comparison between wide and narrow characters. For example this produces FAIL
:
#if L'A' == 'A'
PASS
#else
FAIL
#endif
Also later versions of the standard have u
, U
as equivalents (ISO/IEC 14882 / N3242 :2011(E) 2.14.2 Character literals [lex.ccon], ISO/IEC 9899:2011 6.4.4.4 etc.).
This requires some simple changes to PpToken.evalConstExpr()
and PpTokeniser._sliceCharacterLiteral()
plus tests.
Discovered when processing Python-3.6.2/Python/sysmodule.c
There are some xfailing tests in tests/unit/test_core/test_FileLocation.py
that illustrate the problem. The remedy is being worked on the fileLineColumn
branch.
The preprocessor can be coerced into accidentally pasting tokens to create significant other tokens. For example:
#define PLUS +
+PLUS
This should produce + +
not ++
.
There are some xfailing tests in tests/unit/test_core/test_PpLexer.py
. Search for @pytest.mark.xfail(reason='Need to fix accidental token pasting.')
Some links:
When processing a directory of code each include is rendered in HTML for each translation unit. This is quite expensive in space. The idea is to post process the output of cpipmain
by finding identical files and copying them into a common area and deleting the duplicates. The links need to be updated as well, both ways.
Make a tool cpipduperelink
that accomplishes this.
The root <svg>
element has attributes height
and width
that have values appropriate to 100% scaling. This means when zoomed out (<100%) the browser displays a bigger page than necessary and when zoomed in (>100%) elements outside the page are not displayed.
The function scaleGraphic()
needs to adjust those attribute values on the <svg>
element. Probably the easiest way to do this is to pass them in to scaleGraphic()
as arguments and supply them specifically when writing the <g id="scaleGroup">
group of elements.
I was trying to install the latest version using 'python setup.py install' but the package appears to be incomplete (i.e. cpip.core is missing).
cpipmain --help
Traceback (most recent call last):
File "/usr/local/bin/cpipmain", line 11, in
load_entry_point('cpip==0.9.8rc0', 'console_scripts', 'cpipmain')()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2451, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/local/lib/python3.8/dist-packages/cpip-0.9.8rc0-py3.8.egg/cpip/CPIPMain.py", line 135, in
from cpip import CppCondGraphToHtml
File "/usr/local/lib/python3.8/dist-packages/cpip-0.9.8rc0-py3.8.egg/cpip/CppCondGraphToHtml.py", line 30, in
from cpip.core import CppCond
ModuleNotFoundError: No module named 'cpip.core'
This issue is only significant when processing directories of C code which produces and links to large amounts of near duplicate data.
When processing included file the contents is linked to the macro page. These links, and the macro page are prefixed with the ITU filename. This makes every version of, say Python.h
different even if it is processed with the same macro environment. This makes it impossible to replace common files with a single one that all link to which would reduce duplication hugely.
Change the name of the macro file to just macros.html and all hrefs to that.
PpLexer
has an option annotateLineFile
which, when set True
, provides GCC style annotations. PpLexer
crashes with this option as it makes a call to self._fis.currentFileIsSystemFile
and the currentFileIsSystemFile
attribute does not exist.
There is no test in tests.unit.test_core.test_PpLexer
that uses annotateLineFile=True
.
Some ITU HTML files are not colourised according to their conditional compilation state, instead they are marked as ambiguous.
Some investigation shows that if a file has no conditional compilation directives then that file does not appear in CppCondGraphVisitorConditionalLines
and the call to isCompiled()
raises so ItuToHtml _incAndWriteLine()
treats this as ambiguous.
The solution is that if the path is not in CppCondGraphVisitorConditionalLines
then isCompiled()
should return 1
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.