MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse

Function parse

tools/python-3.11.9-amd64/Lib/ast.py:33–51  ·  view source on GitHub ↗

Parse the source into an AST node. Equivalent to compile(source, filename, mode, PyCF_ONLY_AST). Pass type_comments=True to get back type comments where the syntax allows.

(source, filename='<unknown>', mode='exec', *,
          type_comments=False, feature_version=None)

Source from the content-addressed store, hash-verified

31
32
33def parse(source, filename='<unknown>', mode='exec', *,
34 type_comments=False, feature_version=None):
35 """
36 Parse the source into an AST node.
37 Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
38 Pass type_comments=True to get back type comments where the syntax allows.
39 """
40 flags = PyCF_ONLY_AST
41 if type_comments:
42 flags |= PyCF_TYPE_COMMENTS
43 if isinstance(feature_version, tuple):
44 major, minor = feature_version # Should be a 2-tuple.
45 assert major == 3
46 feature_version = minor
47 elif feature_version is None:
48 feature_version = -1
49 # Else it should be an int giving the minor version for 3.x.
50 return compile(source, filename, mode, flags,
51 _feature_version=feature_version)
52
53
54def literal_eval(node_or_string):

Callers 2

literal_evalFunction · 0.70
mainFunction · 0.70

Calls 1

compileFunction · 0.70

Tested by

no test coverage detected