def _finish_call(self, expr: ex.Expr) -> ex.Call: arguments = [] if not self._check(TokenType.RIGHT_PAREN): arguments.append(self._expression()) while self._match(TokenType.COMMA): if len(arguments) >= 255: self._error(self._peek(), "Can't have more than 255 arguments.") arguments.append(self._expression()) paren = self._consume(TokenType.RIGHT_PAREN, "Expect ')' after arguments.") return ex.Call(expr, paren, arguments)
def finishCall(self, expr): args = [] if not self.check(TokenType.RIGHT_PAREN): args.append(self.expression()) while self.match(TokenType.COMMA): args.append(self.expression()) loc = self.consume(TokenType.RIGHT_PAREN, "Expecting ')' after args") if len(args) > 250: self.error(peek(), "Cannot have more than 250 arguments.") return Expr.Call(expr, loc, args)
def finish_call(self, callee): arguments = [] if not self.check(TokenType.RIGHT_PAREN): arguments.append(self.expression()) while self.match(TokenType.COMMA): if len(arguments) >= 255: self.error(self.peek(), "Cannot have more than 255 args.") arguments.append(self.expression()) paren = self.consume(TokenType.RIGHT_PAREN, "Expect ')' after arguments.") return Expr.Call(callee, paren, arguments)
def finishCall(self, callee: e.Expr) -> e.Expr: arguments: List[e.Expr] = [] if not self.check(TokenType.RIGHT_PAREN): arguments.append(self.expression()) while self.match(TokenType.COMMA): # java has hard 255 limit, c suggests support for at least 127 if len(arguments) >= 255: # report error but don't halt self.error(self.peek(), "Can't have more than 255 arguments.") arguments.append(self.expression()) paren: Token = self.consume(TokenType.RIGHT_PAREN, "Expect ')' after arguments.") return e.Call(callee, paren, arguments)
def visit_ident_or_func(self, node, ch): if len(ch) == 1: return ch[0] if len(ch) == 3: return expr.Call(ch[0], expr.List([])) if isinstance(ch[2], expr.List): return expr.Call(ch[0], ch[2]) return expr.Call(ch[0], expr.List([ch[2]]))