Explain Error Handling.

1 min read In Compiler Design

Programs are written programmers and hence contain many errors. It is the function of its computer to detect and report errors in the source program. The error handling is performed by a program called error handler. Whenever a phase of the compiler discovers an error, it must report the error to the error handler, which issues an appropriate diagnostic message. The various errors encountered by different phases of the compiler can be.

(a) The lyrical analysis phase may detect illegal or unrecognized characters or misspelled tokens.

(b) The parser may detect a syntax error e.g. missing parentheses.

(c) The semantic analyzer may detect a syntactic error e. g. type mismatch. The intermediate code generator may detect an operator with incompatible types.

(d) The code optimizer may detect certain unreachable statements.

(e) The code generator may detect a too large constant to fit in a word of the target machine.

(f) The symbol table may contain multiply declared identifiers with contradictory attributes.

Written by

Asheesh Gupta

Asheesh Gupta is a digital marketer, blogger, and developer helping individuals and businesses grow online through SEO, tools, and modern web solutions since 2014.

Leave a Reply

Your email address will not be published. Required fields are marked *