Comments (3)
Can you provide a minimal, complete reproducer?
from pycparser.
Can you provide a minimal, complete reproducer?
pycparser version:
__version__ = '2.22'
Input:
from pycparser import c_parser, c_generator
src1 = '''
float f1( float __K1, float __K2 ) {
float __left_0 = ( {
float __x1_1 = __K1;
float __x2_1 = __K2;
( __x1_1 < __x2_1 ) ? __x1_1 : __x2_1;
} );
return __left_0;
}
'''
src2 = '''
float f2( float __iz_3, float __T1, float __T2 ) {
float __df_3 = __iz_3 / ( {
float __x1_4 = __T1;
float __x2_4 = __T2;
( __x1_4 > __x2_4 ) ? __x1_4 : __x2_4;
} );
return __df_3;
}
'''
def c2c(src):
parser = c_parser.CParser()
ast = parser.parse(src)
generator = c_generator.CGenerator()
return generator.visit(ast)
print(c2c(src1))
print(c2c(src2))
Output:
/home/artem/PycharmProjects/TestPy3/envs/bin/python /home/artem/PycharmProjects/TestPy3/c2c.py
float f1(float __K1, float __K2)
{
float __left_0 = {
float __x1_1 = __K1;
float __x2_1 = __K2;
(__x1_1 < __x2_1) ? (__x1_1) : (__x2_1);
}
;
return __left_0;
}
Traceback (most recent call last):
File "/home/artem/PycharmProjects/TestPy3/c2c.py", line 32, in <module>
print(c2c(src2))
File "/home/artem/PycharmProjects/TestPy3/c2c.py", line 27, in c2c
ast = parser.parse(src)
File "/home/artem/PycharmProjects/TestPy3/pycparser/c_parser.py", line 147, in parse
return self.cparser.parse(
File "/home/artem/PycharmProjects/TestPy3/pycparser/ply/yacc.py", line 331, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/home/artem/PycharmProjects/TestPy3/pycparser/ply/yacc.py", line 1199, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/artem/PycharmProjects/TestPy3/pycparser/ply/yacc.py", line 193, in call_errorfunc
r = errorfunc(token)
File "/home/artem/PycharmProjects/TestPy3/pycparser/c_parser.py", line 1945, in p_error
self._parse_error(
File "/home/artem/PycharmProjects/TestPy3/pycparser/plyparser.py", line 67, in _parse_error
raise ParseError("%s: %s" % (coord, msg))
pycparser.plyparser.ParseError: :3:32: before: {
Process finished with exit code 1
from pycparser.
Thanks. This is probably not too hard to fix for someone motivated enough to dig into the code. PRs welcome :)
from pycparser.
Related Issues (20)
- Is there a release plan for the next version of pycparser?
- parser error with typedef HOT 10
- assertion error on gcc-9 stddef.h
- Is there a way to find the function declaration matching a function call? HOT 1
- CParser doesn't work with comments HOT 1
- Add end of token coord
- Unable to parse labels at end of block HOT 1
- BUG: pycparser treats empty declarations as a binary operation HOT 1
- TypeError:'Nonetype' object is not callable HOT 5
- "sorry, but this version only supports 100 named groups" HOT 1
- Parsing `va_arg(foo, type)` HOT 3
- Unable to parse through comments and can't support directives HOT 2
- Parser can't handle unknown data types for variables HOT 1
- Parser unbale to handle custom data types for custom functions HOT 1
- Can't parse function declaration with unnamed static array HOT 1
- Implement the collections.abc.Sequence interface for e. g. class Node HOT 1
- c_ast.cpython-*.pyc is rewritten after it is installed
- type cast parsing error in (__typeof(h))spa_meta_first(m) line, __typeof(h) type is not allowed by parser rules HOT 1
- pycparser.plyparser.ParseError when running the example code on .h
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycparser.