Skip to content

Commit

Permalink
address #15 nonparen_genexp_in_call
Browse files Browse the repository at this point in the history
  • Loading branch information
s-cork committed Jun 24, 2021
1 parent 2855e22 commit 94281f7
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/parser/pegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2609,26 +2609,23 @@ export function make_module(p: Parser, a: stmt[]) {
// return RAISE_SYNTAX_ERROR(msg);
// }

// void *
// _PyPegen_nonparen_genexp_in_call(Parser *p, expr_ty args)
// {
// /* The rule that calls this function is 'args for_if_clauses'.
// For the input f(L, x for x in y), L and x are in args and
// the for is parsed as a for_if_clause. We have to check if
// len <= 1, so that input like dict((a, b) for a, b in x)
// gets successfully parsed and then we pass the last
// argument (x in the above example) as the location of the
// error */
// Py_ssize_t len = asdl_seq_LEN(args->v.Call.args);
// if (len <= 1) {
// return NULL;
// }
export function nonparen_genexp_in_call(p: Parser, c: Call) {
/* The rule that calls this function is 'args for_if_clauses'.
For the input f(L, x for x in y), L and x are in args and
the for is parsed as a for_if_clause. We have to check if
len <= 1, so that input like dict((a, b) for a, b in x)
gets successfully parsed and then we pass the last
argument (x in the above example) as the location of the
error */
const args = c.args;
if (args.length <= 1) {
return null;
}

// return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
// (expr_ty) asdl_seq_GET(args->v.Call.args, len - 1),
// "Generator expression must be parenthesized"
// );
// }
/**@todo */
//@ts-ignore
return RAISE_SYNTAX_ERROR_KNOWN_LOCATION(args[args.length - 1], "Generator expression must be parenthesized");
}

// @stu why does our parser not call these functions with the parser?
export function collect_call_seqs(p: Parser, a: expr[], b: KeywordOrStarred[] | null, ...attrs: Attrs) {
Expand Down

0 comments on commit 94281f7

Please sign in to comment.