Syntax Error Handling
Syntax Error
Syntax or Syntactic errors are the errors that arise during syntax analysis. These errors can be the incorrect usage of semicolons, extra braces, or missing braces.
In C or Java, syntactic errors could be a case statement without enclosing the switch.
Syntactic Error Detection
We can detect syntax error through the use of precise parsing methods. The parsing methods, such as LL and LR can detect the errors immediately after their occurrence. They possess viable prefix property according to which an error is triggered whenever a prefix of the input string is not considered as a string. Alternatively, an error is triggered upon encountering the sequence of tokens from the lexical analysis that cannot be parsed any more according to the language grammar.
However, the error handler has to achieve following goals during parsing.
- Address clearly and precisely about the existence of errors. Addressing the error must involve at least referring to the location of an error within the source program.
- Put low overhead for the processing of error-free programs.
- Recover from an error as soon as possible to detect next errors.
Reference Link