(self, opname, token, customize, *args)
| 231 | return |
| 232 | |
| 233 | def custom_classfunc_rule(self, opname, token, customize, *args): |
| 234 | args_pos, args_kw = self.get_pos_kw(token) |
| 235 | |
| 236 | # Additional exprs for * and ** args: |
| 237 | # 0 if neither |
| 238 | # 1 for CALL_FUNCTION_VAR or CALL_FUNCTION_KW |
| 239 | # 2 for * and ** args (CALL_FUNCTION_VAR_KW). |
| 240 | # Yes, this computation based on instruction name is a little bit hoaky. |
| 241 | nak = (len(opname) - len("CALL_FUNCTION")) // 3 |
| 242 | uniq_param = args_kw + args_pos |
| 243 | |
| 244 | if frozenset(("GET_AWAITABLE", "YIELD_FROM")).issubset(self.seen_ops): |
| 245 | rule = ( |
| 246 | "async_call ::= expr " |
| 247 | + ("pos_arg " * args_pos) |
| 248 | + ("kwarg " * args_kw) |
| 249 | + "expr " * nak |
| 250 | + token.kind |
| 251 | + " GET_AWAITABLE LOAD_CONST YIELD_FROM" |
| 252 | ) |
| 253 | self.add_unique_rule(rule, token.kind, uniq_param, customize) |
| 254 | self.add_unique_rule( |
| 255 | "expr ::= async_call", token.kind, uniq_param, customize |
| 256 | ) |
| 257 | |
| 258 | if opname.startswith("CALL_FUNCTION_VAR"): |
| 259 | # Python 3.5 changes the stack position of *args. KW args come |
| 260 | # after *args. |
| 261 | |
| 262 | # Note: Python 3.6+ replaces CALL_FUNCTION_VAR and |
| 263 | # CALL_FUNCTION_VAR_KW with CALL_FUNCTION_EX |
| 264 | |
| 265 | token.kind = self.call_fn_name(token) |
| 266 | if opname.endswith("KW"): |
| 267 | kw = "expr " |
| 268 | else: |
| 269 | kw = "" |
| 270 | rule = ( |
| 271 | "call ::= expr expr " |
| 272 | + ("pos_arg " * args_pos) |
| 273 | + ("kwarg " * args_kw) |
| 274 | + kw |
| 275 | + token.kind |
| 276 | ) |
| 277 | |
| 278 | # Note: semantic actions make use of the fact of whether "args_pos" |
| 279 | # zero or not in creating a template rule. |
| 280 | self.add_unique_rule(rule, token.kind, args_pos, customize) |
| 281 | else: |
| 282 | super(Python35Parser, self).custom_classfunc_rule( |
| 283 | opname, token, customize, *args |
| 284 | ) |
| 285 | |
| 286 | |
| 287 | class Python35ParserSingle(Python35Parser, PythonParserSingle): |
nothing calls this directly
no test coverage detected