split preprocessor-related classes to different file
- Dominant language
- Python
- Stars
- 179
- Forks
- 34
- Avg merge
- 14h 1m
- Merged PRs (30d)
- 1
Description
with the current file structure, it is not possible to implement the **preprocessor** ```#if``` statement, as it would overwrite (or be overwritten by) the **C** ```if ()``` statement.
I would propose to update the file structure to:
```
cgen
+-- cgen
+-- __init__.py
+-- cuda.py
+-- ispc.py
+-- mapper.py
+-- opencl.py
+-- preprocessor
+-- __init__.py
```
and implement the preprocessor ```#if``` (and others preprocessor statements?) in the file ```cgen/preprocessor/__init__.py```.
this would provide access to the preprocessor functionalities like this:
```python
import cgen as c
import cgen.preprocessor as pp
func = c.FunctionBody(
c.FunctionDeclaration(c.Const(c.Pointer(c.Value("char", "greet"))), []),
c.Block([
pp.If('(a == 0)',
[
c.If('b == 0', c.Block([
c.Statement('return "hello world"')
]))
],
[])
])
)
print(func)
```
and will output something like:
```
char const *greet()
{
#if (a == 0)
if (b == 0)
{
return "hello world";
}
#endif
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.