Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parse error (lack thereof) on incomplete loops



On Fri, 2018-10-05 at 13:26 +0000, Daniel Shahaf wrote:
> Can we come up with a one-sided parsing rule for syntactically valid cases?
> That is, a rule that says guarantees that some constructs are syntactically
> valid, but doesn't necessarily say anything about other constructs.

That's pretty much what the the parser in practice does.  If you look at
the code, it's got tests that read...

- If SHORTLOOPS isn't set panic at this point.

- Otherwise go on and see if we can get anything sensible out of what
we did find.

So for example the while loop code has...

    } else if (unset(SHORTLOOPS)) {
	YYERRORV(oecused);
    } else
	par_save_list1(cmplx);

The case that brought this up is that we don't check the return value
from par_save_list1() (actually a macro at the moment).

For more explicit rules it's a question of decoding the tests above (if
we got a "do" then blah, else if we got a "{" then etc. etc.).

pws



Messages sorted by: Reverse Date, Date, Thread, Author