X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Fparsergen.mdc;h=356edef02ef96a4fcc1f1704a8740005dd7acc25;hp=0bef7934d3ec112b77eff4ecd4a007240ff92f34;hb=42d68f83351fb7cc2974e4ef126af258e63cea0f;hpb=1dd9f61bbc7e8890b5407ba084793817e55fe502 diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 0bef793..356edef 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2643,10 +2643,9 @@ to mark the beginning of the file as well as the end. Indents (IN) are sometimes shifted and sometimes only accounted. Whatever decision is made must apply equally to the matching OUT. To -ensure this we keep a stack of bits in `ignored_indents` and -`indent_depth`. When we process an IN, we record if it was ignored. -When we see an out, we pop of the relavant bit and use it to decide how -to handle the OUT. +ensure this we keep a stack of bits in `ignored_indents`. When we +process an IN, we record if it was ignored. When we see an out, we pop +of the relavant bit and use it to decide how to handle the OUT. ###### parser functions @@ -2801,7 +2800,6 @@ need a small stack of flags, which is easily stored as bits in an ###### parser state unsigned long ignored_indents; - int indent_depth; NEWLINE/EOL is ignored when in an indented section of text which was not explicitly expected by the grammar. So if the most recent indent is @@ -2813,10 +2811,10 @@ we try to reduce a production. ###### try shift or ignore if ((tk->num == TK_newline || tk->num == TK_out) && - (p.ignored_indents & (1 << p.indent_depth))) { + (p.ignored_indents & 1)) { /* indented, so ignore OUT and NEWLINE */ if (tk->num == TK_out) - p.indent_depth -= 1; + p.ignored_indents >>= 1; free(tk); tk = NULL; parser_trace_action(trace, "Ignore"); @@ -2826,11 +2824,10 @@ we try to reduce a production. switch (shift(&p, tk->num, tk, states)) { case 1: if (tk->num == TK_out) - p.indent_depth -= 1; - if (tk->num == TK_in) { - p.indent_depth += 1; - p.ignored_indents &= ~(1 << p.indent_depth); - } + p.ignored_indents >>= 1; + if (tk->num == TK_in) + p.ignored_indents <<= 1; + tk = NULL; /* fallthrough */ case 2: @@ -2843,8 +2840,8 @@ we try to reduce a production. /* No indent expected here, so ignore IN */ free(tk); tk = NULL; - p.indent_depth += 1; - p.ignored_indents |= (1 << p.indent_depth); + p.ignored_indents <<= 1; + p.ignored_indents |= 1; parser_trace_action(trace, "Ignore"); continue; }