Skip to content

Commit 1642cc6

Browse files
committed
Simplifying rules for slash_no_default, slash_with_default rules.
1 parent 3ee474f commit 1642cc6

File tree

2 files changed

+1414
-1418
lines changed

2 files changed

+1414
-1418
lines changed

Grammar/python.gram

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,11 @@ parameters[arguments_ty]:
299299
| a=param_with_default+ b=[star_etc] { _PyPegen_make_arguments(p, NULL, NULL, NULL, a, b)}
300300
| a=star_etc { _PyPegen_make_arguments(p, NULL, NULL, NULL, NULL, a) }
301301

302-
# Some duplication here because we can't write (',' | &')'),
303-
# which is because we don't support empty alternatives (yet).
304-
302+
# NOTE: action (void *)1 is needed since &')' is empty alternative.
305303
slash_no_default[asdl_arg_seq*]:
306-
| a[asdl_arg_seq*]=param_no_default+ '/' ',' { a }
307-
| a[asdl_arg_seq*]=param_no_default+ '/' &')' { a }
304+
| a[asdl_arg_seq*]=param_no_default+ '/' (',' | &')' { (void *)1 }) { a }
308305
slash_with_default[SlashWithDefault*]:
309-
| a=param_no_default* b=param_with_default+ '/' ',' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }
310-
| a=param_no_default* b=param_with_default+ '/' &')' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }
306+
| a=param_no_default* b=param_with_default+ '/' (',' | &')' { (void *)1 }) { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }
311307

312308
star_etc[StarEtc*]:
313309
| invalid_star_etc

0 commit comments

Comments
 (0)