You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-8Lines changed: 73 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,17 +55,16 @@
55
55
56
56
## Syntax
57
57
58
-
The syntax for pypreprocessor uses a select subset of the stanard c-style preprocessor directives, and then some...
58
+
The syntax for pypreprocessor uses a select subset of the standard c-style preprocessor directives, and then some...
59
59
60
60
**Supported directives**
61
61
62
-
*define non-value constants used by the preprocessor
62
+
*defines constants (valued or not) used by the preprocessor
63
63
```python
64
-
#define constant
64
+
#define constant [value]
65
65
```
66
66
67
-
68
-
* remove a non-value constant from the list of defined constants
67
+
* removes a constant from the list of defined constants
69
68
```python
70
69
#undef constant
71
70
```
@@ -75,26 +74,46 @@ The syntax for pypreprocessor uses a select subset of the stanard c-style prepro
75
74
#ifdef constant
76
75
```
77
76
78
-
* makes the subsequent block of code available if the specified condition is set
77
+
* makes the subsequent block of code available if the specified constant is not set
78
+
```python
79
+
#ifndef constant
80
+
```
81
+
82
+
* makes the subsequent block of code available if the specified condition returns true
79
83
```python
80
84
#if boolean_condition
81
85
```
82
86
83
-
* makes the subsequent block of code available if all of the preceding #ifdefstatements return false
87
+
* makes the subsequent block of code available if all of the preceding #ifdef, #elif, #if statements returns false
84
88
```python
85
89
#else
86
90
```
87
91
92
+
* makes the subsequent block of code available if all of the preceding #ifdef, #elif, #if statements return false and the specifified condition returns true
93
+
```python
94
+
#elif boolean_condition
95
+
```
96
+
88
97
* required to close out an #ifdef/#else block
89
98
```python
90
99
#endif
91
100
```
101
+
102
+
* Interrupts execution and returns error when reached
103
+
```python
104
+
#error
105
+
```
106
+
107
+
**Unofficial supported directives**
108
+
109
+
Unofficial directives exist to ease writing long files but should not be used in file that could be preprocessed without pypreprocessor
110
+
92
111
* possibility to close all open blocks
93
112
```python
94
113
#endifall
95
114
```
96
115
97
-
*exclude the subsequent block of code (conditionals not included). I know it doesn't fit into the standard set of c-style directives but it's too handy to exclude (no pun).
116
+
*excludes the subsequent block of code (conditionals not included). I know it doesn't fit into the standard set of c-style directives but it's too handy to exclude (no pun).
98
117
```python
99
118
#exclude
100
119
```
@@ -104,6 +123,50 @@ The syntax for pypreprocessor uses a select subset of the stanard c-style prepro
104
123
#endexclude
105
124
```
106
125
126
+
* Attempts closing <num> #ifdef/#else blocks
127
+
```python
128
+
#endif<num>
129
+
```
130
+
131
+
* Similar to #ifndef
132
+
```python
133
+
#ifnotdef constant
134
+
```
135
+
136
+
* Similar to #ifndef
137
+
```python
138
+
#ifdefnot constant
139
+
```
140
+
141
+
* Similar to #elif boolean_condition
142
+
```python
143
+
#elseif boolean_condition
144
+
```
145
+
146
+
* Similar to #elif constant
147
+
```python
148
+
#elseifdef constant
149
+
```
150
+
151
+
* Similar to #endif followed by #ifdef constant
152
+
```python
153
+
#endififdef constant
154
+
```
155
+
156
+
**Unsupported directives**
157
+
158
+
Unsupported directives are not handled by pypreprocessor and concidered as comment
159
+
160
+
* Inserts a particuliar header from another file. This has no use in Python
161
+
```python
162
+
#include
163
+
```
164
+
165
+
* Issues special commands to the compiler, using a standardized method. This has no use in Python
166
+
```python
167
+
#pragma
168
+
```
169
+
107
170
**Options**
108
171
109
172
The following options need to be set prior to pypreprocessor.parse()
@@ -118,12 +181,14 @@ add defines to the preprocessor programmatically, this allows the source file to
118
181
pypreprocessor.run =True/False
119
182
pypreprocessor.resume =True/False
120
183
pypreprocessor.save =True/False
184
+
pypreprocessor.overload =True/False
121
185
```
122
186
set the options of the preprocessor:
123
187
124
188
* run: Run the preprocessed code if true. Default is true
125
189
* resume: Return after a file is preprocessed and can preprocess a next file if true. Default is false
126
190
* save: Save preprocessed code if true. Default is true
191
+
* overload: Any defines added to the preprocessor will overload existing defines. Default is false
0 commit comments