From 2cbbc4c349eaddb6dfe066187b712310dd86d3a0 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Mon, 28 Apr 2025 17:00:51 +0100 Subject: [PATCH] doc: add a document describing potential non-obvious syntax errors the errors documented here include cases where the error is detected far away from where the actual malformed syntax is in the source file, so any error message reported by the compiler needs to include enough information to help the user find and resolve the error. --- doc/error-cases.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 doc/error-cases.txt diff --git a/doc/error-cases.txt b/doc/error-cases.txt new file mode 100644 index 0000000..ee6d28d --- /dev/null +++ b/doc/error-cases.txt @@ -0,0 +1,29 @@ +SYNTAX ERROR CASES TO HANDLE +============================ + + This document describes a range of non-obvious syntax error conditions that + need to be clearly conveyed in error messages. + + + 1 Unterminated expression preceding a for-loop + ---------------------------------------------- + + 1| var x = "Hello, world!" + 2| + 3| for i in 0 to:100 step:2 do + 4| cout put:'Count is {i}' + 5| end + + The statement separator is missing from the end of line 1. However, no + error is detected when the for keyword is encountered due to support for + inline for-loops. + + An error is only reported when the do keyword is encountered, as inline + for-loop do not use this keyword. + + The compiler should alert the user that they may have forgotten a statement + separator at the end of the preceding expression. + + + +vim: shiftwidth=3 expandtab