Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Real compiler script #10

Open
kb-1000 opened this issue May 27, 2018 · 6 comments
Open

Real compiler script #10

kb-1000 opened this issue May 27, 2018 · 6 comments

Comments

@kb-1000
Copy link
Contributor

kb-1000 commented May 27, 2018

A real compiler script with input file options as well as options like -I, -D and -o would be great-

@albertz
Copy link
Owner

albertz commented May 27, 2018

I'm not quite understanding. What do you want to compile it to? This project is not a compiler. It is a parser.

@kb-1000
Copy link
Contributor Author

kb-1000 commented May 27, 2018

@albertz to a Python script, like cpython_static.py is.

markjenkins added a commit to markjenkins/PyCParser that referenced this issue Aug 3, 2018
@markjenkins
Copy link

I've named my take on this runcprog.py.
Example invocation
./runcprog.py example1.c example2.c -- arg1 arg2

There's no -I or -D or any other option parsing (just arguments) but as a substitute for the idea of -D you could put "#define"s in a .h file and make that your first argument, for example you might make mydefines.h and do
./runcprog.py mydefines.h code1.c code2.c -- programarg1 programarg2

As for -I support, that's going to require some deeper hacking in cparser.py to have support for searching multiple directories. Right now, readLocalInclude and the helper findIncludeFullFilename are just working relative to current working directory. A possible work around for that is to invoke runcprog.py with paths to every relevant .h file as the first set of arguments:
runcprog.py headerneeded1.h /usr/local/include/headerneeded2.h code1.c code2.c -- programarg1 programarg2

Comments before a pull request?

@albertz
Copy link
Owner

albertz commented Aug 3, 2018

Ah I see. That looks useful.

About the code: I would avoid the itertools usage, that makes it quite hard to read, and complicated. You could replace that by much shorter code without itertools. Also not_a_dashdash can just be inline where you use it, makes it hard to read as well otherwise.

@kb-1000
Copy link
Contributor Author

kb-1000 commented Aug 3, 2018

I've also created something for this even before I've opened this issue.
It supports -I and -D.
But it's a compiler script, not an interpreter.
Since it's based on the cpython_static.py generation program (with import), I'm currently unable to integrate it.

@albertz
Copy link
Owner

albertz commented Aug 3, 2018

@kaeptmblaubaer1000 Ah, I think I also understand what you have now. This could also be useful.

markjenkins added a commit to markjenkins/PyCParser that referenced this issue Aug 4, 2018
markjenkins added a commit to markjenkins/PyCParser that referenced this issue Aug 4, 2018
dropwhile and takewhile still a thing, going to look for an option
parsing library to simplify "--" handling further (will need anyway for
options)
markjenkins added a commit to markjenkins/PyCParser that referenced this issue Aug 4, 2018
albertz pushed a commit that referenced this issue Aug 9, 2018
dropwhile and takewhile still a thing, going to look for an option
parsing library to simplify "--" handling further (will need anyway for
options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants