inducer / pycparserext

Extensions for Eli Bendersky's pycparser
http://pypi.python.org/pypi/pycparserext
Other
83 stars 28 forks source link

generator.visit of pycparser displaying wrong output in Ubuntu 16.04.3 #31

Closed VerifierIntegerAssignment closed 7 years ago

VerifierIntegerAssignment commented 7 years ago

I have written the following program using pycparser and pycparserext:

from pycparser import parse_file,c_parser, c_ast, c_generator
from pycparserext.ext_c_parser import GnuCParser

content="int main() { int x = 1; int y = 0; while (y < 1000 && __VERIFIER_nondet_int()) { x = x + y; y = y + 1; } __VERIFIER_assert(x >= y); return 0;}"

text = r""" """+content
parser = GnuCParser()
ast = parser.parse(text)
generator = c_generator.CGenerator()
print str(generator.visit(ast))

When I run the code in Mac it returns the correct output. But when I run the same code in Ubuntu 16.04.3 it returns the following incorrect output (that is missing the 'main()':

int{ int x = 1; int y = 0; while ((y < 1000) && __VERIFIER_nondet_int()) { x = x + y; y = y + 1; }

__VERIFIER_assert(x >= y); return 0; } What is causing this incorrect output?

inducer commented 7 years ago

You need to use GnuCGenerator from pycparserext.ext_c_generator.

VerifierIntegerAssignment commented 7 years ago

Thanks a lot