Skip to content

Commit f49ffa1

Browse files
author
Laurent Pinson
committed
README updated
1 parent a74becf commit f49ffa1

File tree

1 file changed

+73
-8
lines changed

1 file changed

+73
-8
lines changed

README.md

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,16 @@
5555

5656
## Syntax
5757

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...
5959

6060
**Supported directives**
6161

62-
* define non-value constants used by the preprocessor
62+
* defines constants (valued or not) used by the preprocessor
6363
```python
64-
#define constant
64+
#define constant [value]
6565
```
6666

67-
68-
* remove a non-value constant from the list of defined constants
67+
* removes a constant from the list of defined constants
6968
```python
7069
#undef constant
7170
```
@@ -75,26 +74,46 @@ The syntax for pypreprocessor uses a select subset of the stanard c-style prepro
7574
#ifdef constant
7675
```
7776

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
7983
```python
8084
#if boolean_condition
8185
```
8286

83-
* makes the subsequent block of code available if all of the preceding #ifdef statements return false
87+
* makes the subsequent block of code available if all of the preceding #ifdef, #elif, #if statements returns false
8488
```python
8589
#else
8690
```
8791

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+
8897
* required to close out an #ifdef/#else block
8998
```python
9099
#endif
91100
```
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+
92111
* possibility to close all open blocks
93112
```python
94113
#endifall
95114
```
96115

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).
98117
```python
99118
#exclude
100119
```
@@ -104,6 +123,50 @@ The syntax for pypreprocessor uses a select subset of the stanard c-style prepro
104123
#endexclude
105124
```
106125

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+
107170
**Options**
108171

109172
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
118181
pypreprocessor.run = True / False
119182
pypreprocessor.resume = True / False
120183
pypreprocessor.save = True / False
184+
pypreprocessor.overload = True / False
121185
```
122186
set the options of the preprocessor:
123187

124188
* run: Run the preprocessed code if true. Default is true
125189
* resume: Return after a file is preprocessed and can preprocess a next file if true. Default is false
126190
* save: Save preprocessed code if true. Default is true
191+
* overload: Any defines added to the preprocessor will overload existing defines. Default is false
127192

128193
```python
129194
pypreprocessor.input = 'inputFile.py'

0 commit comments

Comments
 (0)