---
title: "SU-CS143 APR172025"
source: https://www.jemoka.com/posts/kbhsu_cs143_apr172025/
date: 2025-04-17
---

and also abstract syntax tree and top-down parsing
error handling Recall! Our compiler should detect non-valid programs and to translate valid ones.
Error Kind Example Detected by&hellip; Lexical $ &lt;- doesn&rsquo;t exist lexer Syntax x * % &lt;- doesnt&rsquo; make sense parser Semantic int x; x(3) &lt;- doesn&rsquo;t check type checker Correctness you! Good error handler should report errors accurately and clearly; recovering from an error quickly, and not slow down compilation of valid code.
Error handling ranges from&hellip;.
panic mode error productions automatic local/global correction Not all parser generators support this.
panic mode Consider:
( 1 + + 2 ) + 3 panic mode recovery involves skipping to the next integer and then continue
For instance, our CFG could be:
E -&gt; int | E + E | (E ) | error int | (error) The goal here is to just fast forwarding through the entire error until you see an int.
error production This is how one could get really specific error messages. We will predict some known mistakes and then report them. For instance, people may write 5 x instead of 5*x. We can detect this as a production and just handle it explicitly.
local and global correction Idea: find the locally correct &ldquo;nearby&rdquo; program. Where we try token insertions and deletions until it works, possibly exhaustively.
hard to implement slow down complitaion, etc&hellip;
