refactor scan/parse/compile/eval for better error reporting