py/compile: Combine or_test and and_test compile functions.
This commit is contained in:
parent
1a7109d65a
commit
36e474e83f
11
py/compile.c
11
py/compile.c
|
@ -2024,7 +2024,8 @@ STATIC void compile_lambdef(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
|||
compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist);
|
||||
}
|
||||
|
||||
STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, bool cond) {
|
||||
STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
bool cond = MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test;
|
||||
uint l_end = comp_next_label(comp);
|
||||
int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
|
||||
for (int i = 0; i < n; i += 1) {
|
||||
|
@ -2036,14 +2037,6 @@ STATIC void compile_or_and_test(compiler_t *comp, mp_parse_node_struct_t *pns, b
|
|||
EMIT_ARG(label_assign, l_end);
|
||||
}
|
||||
|
||||
STATIC void compile_or_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
compile_or_and_test(comp, pns, true);
|
||||
}
|
||||
|
||||
STATIC void compile_and_test(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
compile_or_and_test(comp, pns, false);
|
||||
}
|
||||
|
||||
STATIC void compile_not_test_2(compiler_t *comp, mp_parse_node_struct_t *pns) {
|
||||
compile_node(comp, pns->nodes[0]);
|
||||
EMIT_ARG(unary_op, MP_UNARY_OP_NOT);
|
||||
|
|
|
@ -231,8 +231,8 @@ DEF_RULE(lambdef_nocond, c(lambdef), and_blank(4), tok(KW_LAMBDA), opt_rule(vara
|
|||
// power: atom_expr ['**' factor]
|
||||
// atom_expr: 'await' atom trailer* | atom trailer*
|
||||
|
||||
DEF_RULE(or_test, c(or_test), list, rule(and_test), tok(KW_OR))
|
||||
DEF_RULE(and_test, c(and_test), list, rule(not_test), tok(KW_AND))
|
||||
DEF_RULE(or_test, c(or_and_test), list, rule(and_test), tok(KW_OR))
|
||||
DEF_RULE(and_test, c(or_and_test), list, rule(not_test), tok(KW_AND))
|
||||
DEF_RULE_NC(not_test, or(2), rule(not_test_2), rule(comparison))
|
||||
DEF_RULE(not_test_2, c(not_test_2), and(2), tok(KW_NOT), rule(not_test))
|
||||
DEF_RULE(comparison, c(comparison), list, rule(expr), rule(comp_op))
|
||||
|
|
Loading…
Reference in New Issue