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

Re: wrong error msg



On Mar 2,  3:37pm, Ray Andrews wrote:
}
} Although IIRC the most natural parsing system is the way we do it -- 
} outside-in, as, I believe, C does it, but I think the point needs to be 
} hammered in that that's not available to an interpreter.  One of those 
} deep breakages that ruin your life.

Well, no, that's not really it.  The trouble here is that your "natural"
parse is wrong, and the difficulty arises from starting and ending the
matched pair with visually-indistinguishable tokens.  If we replace the
quote marks with square brackets for readability --

The actual meaning:
    echo [Restore \"${previous?\"? (y/n)[

Your "natural" parse:
    echo [Restore \"${previous?\"? (y/n)]

Whether the parse is left-to-right or outside-in doesn't matter.

C does not allow nesting of visually-indistinguishable tokens, so this
can't arise there.

} I see, so rather than collect a cascade of errors, since it can't show 
} the prompt it doesn't even try.  Well .... it could try couldn't it?

The "unmatched" message is coming from the lexer; the PS2 prompt comes
from the interactive input loop after the lexer stops.  There isn't
any "cascade of errors", there's only incomplete parser state, which in
a script is not really available at that point (due to differences in
the way input is processed for interactive vs. a file).

Hmm, you could force interactive mode to syntax-check your script like
this:

  zsh -o interactivecomments +o banghist -fnis < scriptfile
  % dquote braceparam dquote> zsh: unmatched "                                   
  % %                                           

but you'll get a LOT of output.



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