X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Fparsergen.mdc;h=6cb5a7371aa3935663d05df35a186ef8d2a6da32;hp=80027aa74e49989428ea370172c3a783c8ebfd40;hb=69756809ef2d0324ec94b277f9750f92db4ae416;hpb=17b2c8c16fd6dadf052fefc20e2ee8c7f8c3da0b diff --git a/csrc/parsergen.mdc b/csrc/parsergen.mdc index 80027aa..6cb5a73 100644 --- a/csrc/parsergen.mdc +++ b/csrc/parsergen.mdc @@ -2785,11 +2785,12 @@ might also be ignored. Ignoring tokens is combined with shifting. } Indents are ignored unless they can be shifted onto the stack -immediately. The end of an indented section - the OUT token - is -ignored precisely when the indent was ignored. To keep track of this we -need a small stack of flags, which is easily stored as bits in an -`unsigned long`. This will never overflow and the scanner only allows -20 levels of indentation. +immediately or nothing can be shifted (in which case we reduce, and try +again). The end of an indented section - the OUT token - is ignored +precisely when the indent was ignored. To keep track of this we need a +small stack of flags, which is easily stored as bits in an `unsigned +long`. This will never overflow and the scanner only allows 20 levels +of indentation. ###### parser state unsigned long ignored_indents; @@ -2829,8 +2830,8 @@ we try to reduce a production. continue; } - if (tk->num == TK_in) { - /* No indent expected here, so ignore IN */ + if (tk->num == TK_in && states[p.stack[p.tos-1].state].go_to_cnt > 0) { + /* No indent expected here and reduce is not mandatory, so ignore IN */ free(tk); tk = NULL; p.ignored_indents <<= 1;