reduction, or start error handling. 2D tokens (IN, OUT, EOL) also need
to be handled.
+###### parser vars
+
+ struct parser p = { 0 };
+ struct token *tk = NULL;
+ int accepted = 0;
+
+###### heart of parser
+
+ shift(&p, TK_eof, NULL, states);
+ while (!accepted && p.tos > 0) {
+ struct frame *tos = &p.stack[p.tos-1];
+ if (!tk)
+ tk = tok_copy(token_next(tokens));
+ parser_trace(trace, &p,
+ tk, states, non_term, config->known_count);
+
+ ## try shift or ignore
+ ## try reduce
+ ## handle error
+ }
+
+
We return whatever `asn` was returned by reducing production zero.
When we find `TK_in` and `TK_out` tokens which report indents we need
FILE *trace, const char *non_term[],
struct token_config *config)
{
- struct parser p = { 0 };
- struct token *tk = NULL;
- int accepted = 0;
## parser vars
- shift(&p, TK_eof, NULL, states);
- while (!accepted && p.tos > 0) {
- struct frame *tos = &p.stack[p.tos-1];
- if (!tk)
- tk = tok_copy(token_next(tokens));
- parser_trace(trace, &p,
- tk, states, non_term, config->known_count);
+ ## heart of parser
- ## try shift or ignore
- ## try reduce
- ## handle error
- }
free(tk);
pop(&p, p.tos, do_free);
free(p.asn_stack);