]> ocean-lang.org Git - ocean/commitdiff
parsergen: get rid of 'next' in parser_run()
authorNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 03:26:33 +0000 (13:26 +1000)
committerNeilBrown <neil@brown.name>
Fri, 3 Oct 2014 03:26:33 +0000 (13:26 +1000)
It isn't used for anything useful any more.

Signed-off-by: NeilBrown <neil@brown.name>
csrc/parsergen.mdc

index 13d0ef654251d27220a46b69224ea99814325c7e..136cdf62c923d0ddcf7b305e96757c939983fcb2 100644 (file)
@@ -2652,7 +2652,6 @@ since the last state which could have been at the start of a line.
                         struct token_config *config)
        {
                struct parser p = { 0 };
-               struct frame next = { 0 };
                struct token *tk = NULL;
                int accepted = 0;
                void *ret = NULL;
@@ -2663,11 +2662,10 @@ since the last state which could have been at the start of a line.
                        struct frame *tos = &p.stack[p.tos-1];
                        if (!tk)
                                tk = tok_copy(token_next(tokens));
-                       next.sym = tk->num;
-                       parser_trace(trace, &p, !next.since_newline,
+                       parser_trace(trace, &p,
                                     tk, states, non_term, config->known_count);
 
-                       if (next.sym == TK_in) {
+                       if (tk->num == TK_in) {
                                tos->indents += 1;
                                tos->since_newline = 0;
                                tos->since_indent = 0;
@@ -2678,7 +2676,7 @@ since the last state which could have been at the start of a line.
                                parser_trace_action(trace, "Record");
                                continue;
                        }
-                       if (next.sym == TK_out) {
+                       if (tk->num == TK_out) {
                                if (states[tos->state].reduce_size >= 0 &&
                                    states[tos->state].reduce_size <= tos->since_indent)
                                        goto force_reduce;
@@ -2714,7 +2712,7 @@ since the last state which could have been at the start of a line.
                                // fall through and force a REDUCE (as 'shift'
                                // will fail).
                        }
-                       if (next.sym == TK_newline) {
+                       if (tk->num == TK_newline) {
                                if (!tos->newline_permitted) {
                                        free(tk);
                                        tk = NULL;
@@ -2726,7 +2724,6 @@ since the last state which could have been at the start of a line.
                                        goto force_reduce;
                        }
                        if (shift(&p, tk->num, 0, tk->num == TK_newline, tk, states)) {
-                               next.since_newline = !(tk->num == TK_newline);
                                tk = NULL;
                                parser_trace_action(trace, "Shift");
                                continue;
@@ -2786,8 +2783,7 @@ since the last state which could have been at the start of a line.
                        short indents = 0, start_of_line;
 
                        err_tk = tok_copy(*tk);
-                       next.sym = TK_error;
-                       while (shift(&p, TK_error, 0, !next.since_newline,
+                       while (shift(&p, TK_error, 0, 0,
                                     err_tk, states) == 0
                               && p.tos > 0)
                                // discard this state
@@ -2868,7 +2864,7 @@ end inside square brackets.
                fprintf(trace, ") ");
        }
 
-       void parser_trace(FILE *trace, struct parser *p, int start_of_line,
+       void parser_trace(FILE *trace, struct parser *p,
                          struct token *tk, const struct state states[],
                          const char *non_term[], int knowns)
        {
@@ -2902,8 +2898,6 @@ end inside square brackets.
                        fputs(reserved_words[tk->num], trace);
                else
                        text_dump(trace, tk->txt, 20);
-               if (start_of_line)
-                       fputs("/", trace);
                fputs("]", trace);
        }