Search code examples
error-handlingcommon-lispuser-input

Error Checking for a User Input File


I've written (and mostly debugged) a program that processes a user input file made up of macro calls. I'd like to now add thorough error checking on the user input file. Is there a general best practices approach for performing syntactic & semantic error checking on such a file? Three basic approaches I can think of are 1) to write a separate preprocessing program to validate the file, 2) to specify a BNF and use an off-the-shelf compiler-compiler as a preprocessor, or 3) to integrate error checks into the existing program. The third approach seems like it might be better, since it may enable deeper semantic checks? I would like to know the pros & cons for these and other approaches.


Solution

  • Thank you coredump & BRFennPocock for the benefit of your experience. I'll take your advice and embed the error checks in the existing program, although it is sure to be an error^2 prone task to try to catch everything. There is no advance whitelist, but I could build one from the user's input, and then check for consistency among all uses (e.g., to cover misspellings). The majority of the asserts & check-types look like they will occur at load time. Thanks again.