| | | |
Offset 144, 25 lines modified | Offset 144, 25 lines modified |
144 | .UNINDENT | 144 | .UNINDENT |
145 | .UNINDENT | 145 | .UNINDENT |
146 | .SS·Loading·a·Grammar | 146 | .SS·Loading·a·Grammar |
147 | .sp | 147 | .sp |
148 | Typically·if·you·want·to·work·with·one·specific·Python·version,·use: | 148 | Typically·if·you·want·to·work·with·one·specific·Python·version,·use: |
149 | .INDENT·0.0 | 149 | .INDENT·0.0 |
150 | .TP | 150 | .TP |
151 | .B·parso.load_grammar(*,·version:··str··=··None,·path:··str··=··None) | 151 | .B·parso.load_grammar(*,·version:··\fI\%str\fP··=··None,·path:··\fI\%str\fP··=··None) |
152 | Loads·a·\fI\%parso.Grammar\fP\&.·The·default·version·is·the·current·Python | 152 | Loads·a·\fI\%parso.Grammar\fP\&.·The·default·version·is·the·current·Python |
153 | version. | 153 | version. |
154 | .INDENT·7.0 | 154 | .INDENT·7.0 |
155 | .TP | 155 | .TP |
156 | .B·Parameters | 156 | .B·Parameters |
157 | .INDENT·7.0 | 157 | .INDENT·7.0 |
158 | .IP·\(bu·2 | 158 | .IP·\(bu·2 |
159 | \fBversion\fP·(\fIstr\fP)·\-\-·A·python·version·string,·e.g.·\fBversion=\(aq3.8\(aq\fP\&. | 159 | \fBversion\fP·(\fI\%str\fP)·\-\-·A·python·version·string,·e.g.·\fBversion=\(aq3.8\(aq\fP\&. |
160 | .IP·\(bu·2 | 160 | .IP·\(bu·2 |
161 | \fBpath\fP·(\fIstr\fP)·\-\-·A·path·to·a·grammar·file | 161 | \fBpath\fP·(\fI\%str\fP)·\-\-·A·path·to·a·grammar·file |
162 | .UNINDENT | 162 | .UNINDENT |
163 | .UNINDENT | 163 | .UNINDENT |
164 | .UNINDENT | 164 | .UNINDENT |
165 | .SS·Grammar·methods | 165 | .SS·Grammar·methods |
166 | .sp | 166 | .sp |
167 | You·will·get·back·a·grammar·object·that·you·can·use·to·parse·code·and·find | 167 | You·will·get·back·a·grammar·object·that·you·can·use·to·parse·code·and·find |
168 | issues·in·it: | 168 | issues·in·it: |
Offset 175, 52 lines modified | Offset 175, 52 lines modified |
175 | .INDENT·7.0 | 175 | .INDENT·7.0 |
176 | .TP | 176 | .TP |
177 | .B·Parameters | 177 | .B·Parameters |
178 | \fBtext\fP·\-\-·A·BNF·representation·of·your·grammar. | 178 | \fBtext\fP·\-\-·A·BNF·representation·of·your·grammar. |
179 | .UNINDENT | 179 | .UNINDENT |
180 | .INDENT·7.0 | 180 | .INDENT·7.0 |
181 | .TP | 181 | .TP |
182 | .B·parse(code:··str··|··bytes··=··None,·*,·error_recovery=True,·path:··PathLike··|··str··=··None,·start_symbol:··str··=··None,·cache=False,·diff_cache=False,·cache_path:··PathLike··|··str··=··None,·file_io:··FileIO··=··None)·->·_NodeT | 182 | .B·parse(code:··\fI\%str\fP··|··\fI\%bytes\fP··=··None,·*,·error_recovery=True,·path:··\fI\%PathLike\fP··|··\fI\%str\fP··=··None,·start_symbol:··\fI\%str\fP··=··None,·cache=False,·diff_cache=False,·cache_path:··\fI\%PathLike\fP··|··\fI\%str\fP··=··None,·file_io:··FileIO··=··None)·->·_NodeT |
183 | If·you·want·to·parse·a·Python·file·you·want·to·start·here,·most·likely. | 183 | If·you·want·to·parse·a·Python·file·you·want·to·start·here,·most·likely. |
184 | .sp | 184 | .sp |
185 | If·you·need·finer·grained·control·over·the·parsed·instance,·there·will·be | 185 | If·you·need·finer·grained·control·over·the·parsed·instance,·there·will·be |
186 | other·ways·to·access·it. | 186 | other·ways·to·access·it. |
187 | .INDENT·7.0 | 187 | .INDENT·7.0 |
188 | .TP | 188 | .TP |
189 | .B·Parameters | 189 | .B·Parameters |
190 | .INDENT·7.0 | 190 | .INDENT·7.0 |
191 | .IP·\(bu·2 | 191 | .IP·\(bu·2 |
192 | \fBcode\fP·(\fIstr\fP)·\-\-·A·unicode·or·bytes·string.·When·it\(aqs·not·possible·to | 192 | \fBcode\fP·(\fI\%str\fP)·\-\-·A·unicode·or·bytes·string.·When·it\(aqs·not·possible·to |
193 | decode·bytes·to·a·string,·returns·a | 193 | decode·bytes·to·a·string,·returns·a |
194 | \fBUnicodeDecodeError\fP\&. | 194 | \fI\%UnicodeDecodeError\fP\&. |
195 | .IP·\(bu·2 | 195 | .IP·\(bu·2 |
196 | \fBerror_recovery\fP·(\fIbool\fP)·\-\-·If·enabled,·any·code·will·be·returned.·If | 196 | \fBerror_recovery\fP·(\fI\%bool\fP)·\-\-·If·enabled,·any·code·will·be·returned.·If |
197 | it·is·invalid,·it·will·be·returned·as·an·error·node.·If·disabled, | 197 | it·is·invalid,·it·will·be·returned·as·an·error·node.·If·disabled, |
198 | you·will·get·a·ParseError·when·encountering·syntax·errors·in·your | 198 | you·will·get·a·ParseError·when·encountering·syntax·errors·in·your |
199 | code. | 199 | code. |
200 | .IP·\(bu·2 | 200 | .IP·\(bu·2 |
201 | \fBstart_symbol\fP·(\fIstr\fP)·\-\-·The·grammar·rule·(nonterminal)·that·you·want | 201 | \fBstart_symbol\fP·(\fI\%str\fP)·\-\-·The·grammar·rule·(nonterminal)·that·you·want |
202 | to·parse.·Only·allowed·to·be·used·when·error_recovery·is·False. | 202 | to·parse.·Only·allowed·to·be·used·when·error_recovery·is·False. |
203 | .IP·\(bu·2 | 203 | .IP·\(bu·2 |
204 | \fBpath\fP·(\fIstr\fP)·\-\-·The·path·to·the·file·you·want·to·open.·Only·needed·for·caching. | 204 | \fBpath\fP·(\fI\%str\fP)·\-\-·The·path·to·the·file·you·want·to·open.·Only·needed·for·caching. |
205 | .IP·\(bu·2 | 205 | .IP·\(bu·2 |
206 | \fBcache\fP·(\fIbool\fP)·\-\-·Keeps·a·copy·of·the·parser·tree·in·RAM·and·on·disk | 206 | \fBcache\fP·(\fI\%bool\fP)·\-\-·Keeps·a·copy·of·the·parser·tree·in·RAM·and·on·disk |
207 | if·a·path·is·given.·Returns·the·cached·trees·if·the·corresponding | 207 | if·a·path·is·given.·Returns·the·cached·trees·if·the·corresponding |
208 | files·on·disk·have·not·changed.·Note·that·this·stores·pickle·files | 208 | files·on·disk·have·not·changed.·Note·that·this·stores·pickle·files |
209 | on·your·file·system·(e.g.·for·Linux·in·\fB~/.cache/parso/\fP). | 209 | on·your·file·system·(e.g.·for·Linux·in·\fB~/.cache/parso/\fP). |
210 | .IP·\(bu·2 | 210 | .IP·\(bu·2 |
211 | \fBdiff_cache\fP·(\fIbool\fP)·\-\-·Diffs·the·cached·python·module·against·the·new | 211 | \fBdiff_cache\fP·(\fI\%bool\fP)·\-\-·Diffs·the·cached·python·module·against·the·new |
212 | code·and·tries·to·parse·only·the·parts·that·have·changed.·Returns | 212 | code·and·tries·to·parse·only·the·parts·that·have·changed.·Returns |
213 | the·same·(changed)·module·that·is·found·in·cache.·Using·this·option | 213 | the·same·(changed)·module·that·is·found·in·cache.·Using·this·option |
214 | requires·you·to·not·do·anything·anymore·with·the·cached·modules | 214 | requires·you·to·not·do·anything·anymore·with·the·cached·modules |
215 | under·that·path,·because·the·contents·of·it·might·change.·This | 215 | under·that·path,·because·the·contents·of·it·might·change.·This |
216 | option·is·still·somewhat·experimental.·If·you·want·stability, | 216 | option·is·still·somewhat·experimental.·If·you·want·stability, |
217 | please·don\(aqt·use·it. | 217 | please·don\(aqt·use·it. |
218 | .IP·\(bu·2 | 218 | .IP·\(bu·2 |
219 | \fBcache_path\fP·(\fIbool\fP)·\-\-·If·given·saves·the·parso·cache·in·this | 219 | \fBcache_path\fP·(\fI\%bool\fP)·\-\-·If·given·saves·the·parso·cache·in·this |
220 | directory.·If·not·given,·defaults·to·the·default·cache·places·on | 220 | directory.·If·not·given,·defaults·to·the·default·cache·places·on |
221 | each·platform. | 221 | each·platform. |
222 | .UNINDENT | 222 | .UNINDENT |
223 | .TP | 223 | .TP |
224 | .B·Returns | 224 | .B·Returns |
225 | A·subclass·of·\fI\%parso.tree.NodeOrLeaf\fP\&.·Typically·a | 225 | A·subclass·of·\fI\%parso.tree.NodeOrLeaf\fP\&.·Typically·a |
226 | \fI\%parso.python.tree.Module\fP\&. | 226 | \fI\%parso.python.tree.Module\fP\&. |
Offset 269, 42 lines modified | Offset 269, 42 lines modified |
269 | .TP | 269 | .TP |
270 | .B·parso.parse(code=None,·**kwargs) | 270 | .B·parso.parse(code=None,·**kwargs) |
271 | A·utility·function·to·avoid·loading·grammars. | 271 | A·utility·function·to·avoid·loading·grammars. |
272 | Params·are·documented·in·\fI\%parso.Grammar.parse()\fP\&. | 272 | Params·are·documented·in·\fI\%parso.Grammar.parse()\fP\&. |
273 | .INDENT·7.0 | 273 | .INDENT·7.0 |
274 | .TP | 274 | .TP |
275 | .B·Parameters | 275 | .B·Parameters |
276 | \fBversion\fP·(\fIstr\fP)·\-\-·The·version·used·by·\fI\%parso.load_grammar()\fP\&. | 276 | \fBversion\fP·(\fI\%str\fP)·\-\-·The·version·used·by·\fI\%parso.load_grammar()\fP\&. |
277 | .UNINDENT | 277 | .UNINDENT |
278 | .UNINDENT | 278 | .UNINDENT |
279 | .INDENT·0.0 | 279 | .INDENT·0.0 |
280 | .TP | 280 | .TP |
281 | .B·parso.split_lines(string:··str,·keepends:··bool··=··False)·->·Sequence[str] | 281 | .B·parso.split_lines(string:··\fI\%str\fP,·keepends:··\fI\%bool\fP··=··False)·->·\fI\%Sequence\fP[\fI\%str\fP] |
282 | Intended·for·Python·code.·In·contrast·to·Python\(aqs·\fBstr.splitlines()\fP, | 282 | Intended·for·Python·code.·In·contrast·to·Python\(aqs·\fI\%str.splitlines()\fP, |
283 | looks·at·form·feeds·and·other·special·characters·as·normal·text.·Just | 283 | looks·at·form·feeds·and·other·special·characters·as·normal·text.·Just |
284 | splits·\fB\en\fP·and·\fB\er\en\fP\&. | 284 | splits·\fB\en\fP·and·\fB\er\en\fP\&. |
285 | Also·different:·Returns·\fB[\(dq\(dq]\fP·for·an·empty·string·input. | 285 | Also·different:·Returns·\fB[\(dq\(dq]\fP·for·an·empty·string·input. |
286 | .sp | 286 | .sp |
287 | In·Python·2.7·form·feeds·are·used·as·normal·characters·when·using | 287 | In·Python·2.7·form·feeds·are·used·as·normal·characters·when·using |
288 | str.splitlines.·However·in·Python·3·somewhere·there·was·a·decision·to·split | 288 | str.splitlines.·However·in·Python·3·somewhere·there·was·a·decision·to·split |
289 | also·on·form·feeds. | 289 | also·on·form·feeds. |
290 | .UNINDENT | 290 | .UNINDENT |
291 | .INDENT·0.0 | 291 | .INDENT·0.0 |
292 | .TP | 292 | .TP |
293 | .B·parso.python_bytes_to_unicode(source:··str··|··bytes,·encoding:··str··=··\(aqutf\-8\(aq,·errors:··str··=··\(aqstrict\(aq)·->·str | 293 | .B·parso.python_bytes_to_unicode(source:··\fI\%str\fP··|··\fI\%bytes\fP,·encoding:··\fI\%str\fP··=··\(aqutf\-8\(aq,·errors:··\fI\%str\fP··=··\(aqstrict\(aq)·->·\fI\%str\fP |
294 | Checks·for·unicode·BOMs·and·PEP·263·encoding·declarations.·Then·returns·a | 294 | Checks·for·unicode·BOMs·and·PEP·263·encoding·declarations.·Then·returns·a |
295 | unicode·object·like·in·\fBbytes.decode()\fP\&. | 295 | unicode·object·like·in·\fI\%bytes.decode()\fP\&. |
296 | .INDENT·7.0 | 296 | .INDENT·7.0 |
297 | .TP | 297 | .TP |
298 | .B·Parameters | 298 | .B·Parameters |
299 | .INDENT·7.0 | 299 | .INDENT·7.0 |
300 | .IP·\(bu·2 | 300 | .IP·\(bu·2 |
301 | \fBencoding\fP·\-\-·See·\fBbytes.decode()\fP·documentation. | 301 | \fBencoding\fP·\-\-·See·\fI\%bytes.decode()\fP·documentation. |
302 | .IP·\(bu·2 | 302 | .IP·\(bu·2 |
303 | \fBerrors\fP·\-\-·See·\fBbytes.decode()\fP·documentation.·\fBerrors\fP·can·be | 303 | \fBerrors\fP·\-\-·See·\fI\%bytes.decode()\fP·documentation.·\fBerrors\fP·can·be |
304 | \fB\(aqstrict\(aq\fP,·\fB\(aqreplace\(aq\fP·or·\fB\(aqignore\(aq\fP\&. | 304 | \fB\(aqstrict\(aq\fP,·\fB\(aqreplace\(aq\fP·or·\fB\(aqignore\(aq\fP\&. |
305 | .UNINDENT | 305 | .UNINDENT |
306 | .UNINDENT | 306 | .UNINDENT |
307 | .UNINDENT | 307 | .UNINDENT |
308 | .SS·Used·By | 308 | .SS·Used·By |
309 | .INDENT·0.0 | 309 | .INDENT·0.0 |
310 | .IP·\(bu·2 | 310 | .IP·\(bu·2 |
Offset 325, 27 lines modified | Offset 325, 27 lines modified |
325 | .UNINDENT | 325 | .UNINDENT |
326 | .SS·Parser·Tree·Base·Classes | 326 | .SS·Parser·Tree·Base·Classes |
327 | .sp | 327 | .sp |
328 | Generally·there·are·two·types·of·classes·you·will·deal·with: | 328 | Generally·there·are·two·types·of·classes·you·will·deal·with: |
329 | \fI\%parso.tree.Leaf\fP·and·\fI\%parso.tree.BaseNode\fP\&. | 329 | \fI\%parso.tree.Leaf\fP·and·\fI\%parso.tree.BaseNode\fP\&. |
Max diff block lines reached; 26970/33423 bytes (80.69%) of diff not shown.
|