summaryrefslogtreecommitdiff
path: root/py/grammar.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-27 16:46:51 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-27 16:46:51 +0100
commit2c0842b3c57a1f2a6556690c6ca7c224d49144d8 (patch)
treef29e71b2f4405037bc6f1c58204483cd84161147 /py/grammar.h
parent2827d62e8b5790b2d770b9ce54e25cd56e949f20 (diff)
py: Change the way function arguments are compiled.
New way uses slightly less ROM and RAM, should be slightly faster, and, most importantly, allows to catch the error "non-keyword arg following keyword arg". Addresses issue #466.
Diffstat (limited to 'py/grammar.h')
-rw-r--r--py/grammar.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/grammar.h b/py/grammar.h
index 4823ccb12..20c468298 100644
--- a/py/grammar.h
+++ b/py/grammar.h
@@ -275,10 +275,10 @@ DEF_RULE(classdef_2, nc, and(3), tok(DEL_PAREN_OPEN), opt_rule(arglist), tok(DEL
// arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)
// TODO arglist lets through more than is allowed, compiler needs to do further verification
-DEF_RULE(arglist, c(generic_all_nodes), list_with_end, rule(arglist_2), tok(DEL_COMMA))
+DEF_RULE(arglist, nc, list_with_end, rule(arglist_2), tok(DEL_COMMA))
DEF_RULE(arglist_2, nc, or(3), rule(arglist_star), rule(arglist_dbl_star), rule(argument))
-DEF_RULE(arglist_star, c(arglist_star), and(2), tok(OP_STAR), rule(test))
-DEF_RULE(arglist_dbl_star, c(arglist_dbl_star), and(2), tok(OP_DBL_STAR), rule(test))
+DEF_RULE(arglist_star, nc, and(2), tok(OP_STAR), rule(test))
+DEF_RULE(arglist_dbl_star, nc, and(2), tok(OP_DBL_STAR), rule(test))
// # The reason that keywords are test nodes instead of NAME is that using NAME
// # results in an ambiguity. ast.c makes sure it's a NAME.
@@ -287,7 +287,7 @@ DEF_RULE(arglist_dbl_star, c(arglist_dbl_star), and(2), tok(OP_DBL_STAR), rule(t
// comp_for: 'for' exprlist 'in' or_test [comp_iter]
// comp_if: 'if' test_nocond [comp_iter]
-DEF_RULE(argument, c(argument), and(2), rule(test), opt_rule(argument_2))
+DEF_RULE(argument, nc, and(2), rule(test), opt_rule(argument_2))
DEF_RULE(argument_2, nc, or(2), rule(comp_for), rule(argument_3))
DEF_RULE(argument_3, nc, and(2), tok(DEL_EQUAL), rule(test))
DEF_RULE(comp_iter, nc, or(2), rule(comp_for), rule(comp_if))