aboutsummaryrefslogtreecommitdiff
path: root/py/parse.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-12-23 23:53:01 +1100
committerDamien George <damien.p.george@gmail.com>2017-12-28 23:12:10 +1100
commit66d8885d85bb591810b25e763c0921372ab74ef4 (patch)
tree0de473662066f6ba4414f03aa6e0168460bd44b0 /py/parse.c
parent815a8cd1ae3a0a451b0b0b687277093f3392cdab (diff)
py/parse: Pass rule_id to push_result_token, instead of passing rule_t*.
Diffstat (limited to 'py/parse.c')
-rw-r--r--py/parse.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/py/parse.c b/py/parse.c
index fffa98953..6244af432 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -414,7 +414,7 @@ STATIC mp_parse_node_t mp_parse_node_new_small_int_checked(parser_t *parser, mp_
return mp_parse_node_new_small_int(val);
}
-STATIC void push_result_token(parser_t *parser, const rule_t *rule) {
+STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
mp_parse_node_t pn;
mp_lexer_t *lex = parser->lexer;
if (lex->tok_kind == MP_TOKEN_NAME) {
@@ -422,7 +422,7 @@ STATIC void push_result_token(parser_t *parser, const rule_t *rule) {
#if MICROPY_COMP_CONST
// if name is a standalone identifier, look it up in the table of dynamic constants
mp_map_elem_t *elem;
- if (rule->rule_id == RULE_atom
+ if (rule_id == RULE_atom
&& (elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP)) != NULL) {
if (MP_OBJ_IS_SMALL_INT(elem->value)) {
pn = mp_parse_node_new_small_int_checked(parser, elem->value);
@@ -433,7 +433,7 @@ STATIC void push_result_token(parser_t *parser, const rule_t *rule) {
pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id);
}
#else
- (void)rule;
+ (void)rule_id;
pn = mp_parse_node_new_leaf(MP_PARSE_NODE_ID, id);
#endif
} else if (lex->tok_kind == MP_TOKEN_INTEGER) {
@@ -846,7 +846,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
uint16_t kind = rule->arg[i] & RULE_ARG_KIND_MASK;
if (kind == RULE_ARG_TOK) {
if (lex->tok_kind == (rule->arg[i] & RULE_ARG_ARG_MASK)) {
- push_result_token(&parser, rule);
+ push_result_token(&parser, rule->rule_id);
mp_lexer_to_next(lex);
goto next_rule;
}
@@ -890,7 +890,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
if (lex->tok_kind == tok_kind) {
// matched token
if (tok_kind == MP_TOKEN_NAME) {
- push_result_token(&parser, rule);
+ push_result_token(&parser, rule->rule_id);
}
mp_lexer_to_next(lex);
} else {
@@ -1022,7 +1022,7 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) {
if (i & 1 & n) {
// separators which are tokens are not pushed to result stack
} else {
- push_result_token(&parser, rule);
+ push_result_token(&parser, rule->rule_id);
}
mp_lexer_to_next(lex);
// got element of list, so continue parsing list