MCPcopy Index your code
hub / github.com/python/cpython / visit_NameLeaf

Method visit_NameLeaf

Tools/peg_generator/pegen/c_generator.py:158–190  ·  view source on GitHub ↗
(self, node: NameLeaf)

Source from the content-addressed store, hash-verified

156 )
157
158 def visit_NameLeaf(self, node: NameLeaf) -> FunctionCall:
159 name = node.value
160 if name in self.non_exact_tokens:
161 if name in BASE_NODETYPES:
162 return FunctionCall(
163 assigned_variable=f"{name.lower()}_var",
164 function=f"_PyPegen_{name.lower()}_token",
165 arguments=["p"],
166 nodetype=BASE_NODETYPES[name],
167 return_type="expr_ty",
168 comment=name,
169 )
170 return FunctionCall(
171 assigned_variable=f"{name.lower()}_var",
172 function="_PyPegen_expect_token",
173 arguments=["p", name],
174 nodetype=NodeTypes.GENERIC_TOKEN,
175 return_type="Token *",
176 comment=f"token='{name}'",
177 )
178
179 type = None
180 rule = self.gen.all_rules.get(name.lower())
181 if rule is not None:
182 type = "asdl_seq *" if rule.is_loop() or rule.is_gather() else rule.type
183
184 return FunctionCall(
185 assigned_variable=f"{name}_var",
186 function=f"{name}_rule",
187 arguments=["p"],
188 return_type=type,
189 comment=f"{node}",
190 )
191
192 def visit_StringLeaf(self, node: StringLeaf) -> FunctionCall:
193 val = ast.literal_eval(node.value)

Callers

nothing calls this directly

Calls 5

FunctionCallClass · 0.85
is_loopMethod · 0.80
is_gatherMethod · 0.80
lowerMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected