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

Method visit_StringLeaf

Tools/peg_generator/pegen/c_generator.py:192–209  ·  view source on GitHub ↗
(self, node: StringLeaf)

Source from the content-addressed store, hash-verified

190 )
191
192 def visit_StringLeaf(self, node: StringLeaf) -> FunctionCall:
193 val = ast.literal_eval(node.value)
194 if re.match(r"[a-zA-Z_]\w*\Z", val): # This is a keyword
195 if node.value.endswith("'"):
196 return self.keyword_helper(val)
197 else:
198 return self.soft_keyword_helper(node.value)
199 else:
200 assert val in self.exact_tokens, f"{node.value} is not a known literal"
201 type = self.exact_tokens[val]
202 return FunctionCall(
203 assigned_variable="_literal",
204 function="_PyPegen_expect_token",
205 arguments=["p", type],
206 nodetype=NodeTypes.GENERIC_TOKEN,
207 return_type="Token *",
208 comment=f"token='{val}'",
209 )
210
211 def visit_NamedItem(self, node: NamedItem) -> FunctionCall:
212 call = self.generate_call(node.item)

Callers

nothing calls this directly

Calls 5

keyword_helperMethod · 0.95
soft_keyword_helperMethod · 0.95
FunctionCallClass · 0.85
matchMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected