chiark / gitweb /
src/final.lisp: Improve `test-parser' for testing error reporting.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 8 Jun 2018 18:58:28 +0000 (19:58 +0100)
commit2b7ce7a531298ef50fe6fd98126485cc56175b02
tree94c48357523a5c15cfe11a12a6d71fb010ae6f88
parentc6ec484fcf13c0faab6ce5bbbb6ff510387763a5
src/final.lisp: Improve `test-parser' for testing error reporting.

This is nearly a rewrite.  By default, print errors and warnings
encountered during the parse, so that I can test how well the various
parsers cope with errors.  The output has changed, and there's a new
`:backtrace' keyword argument for disabling the error-trapping, to make
it easier to track down unexpected errors.

The new code is a little tricky.  A `token-scanner' tries to lex its
first token during initialization (`priming the pump'), and can
therefore emit lexical errors at this point.  We must therefore
establish `count-and-report-errors' around construction of the token
scanner; but it shouldn't be wrapped around the output stage -- partly
because I think I want to debug errors in that in the traditional way,
but mostly because the output includes the error counts.

So declare the scanner variables early, but initialize them later,
inside the body function.  This leaves a further problem: if priming the
pump fails badly, then `scanner' won't get set; so guard the final
output item from silliness in this case.
doc/misc.tex
src/final.lisp