Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In general <strong>the more complex the error, the more complex the code for asserting the error</strong>. Lexers and parsers are fairly simple (in practice), and therefore catch simple errors.</p> <ol> <li><strong>Lexers</strong> catch invalid sequences of characters supposed to make up a <strong>token</strong></li> <li><strong>syntax analysis</strong> tools such as Bison/Yacc catch invalid sequences of tokens that make up <strong>syntax</strong> and statements.</li> </ol> <p><strong>Complex</strong> errors usually happen elsewhere at runtime or in various translations at compile-time. Examples might include referencing a function/method that doesn't exist. Closure scopes / binding, object and reference identifiers, argument validity, overloading, and tons of other language dependent stuff.</p> <p>Anything outside that very narrow token/syntax scope is (or should be handled) well outside those tools in AST analysis or intermediate code generation.</p> <p>Consider:</p> <pre><code>a.b(); ab(); </code></pre> <p>Both <em>should</em> make it through the lexer/parser for an object oriented language where both statements are valid. <strong>is there an error?</strong></p> <ol> <li><p>Your compiler might assert this at <strong>compile time</strong> if the language is a fairly static one and identifiers can be resolved at compile time. </p></li> <li><p>You might replace both statements with ID resolution code to be run at <strong>runtime</strong> to produce a runtime error rather than a compiler error.</p></li> </ol> <p>The differences between runtime and compile-time resolution and semantics can be subtle and widely different from language to language.</p> <p>Errors are usually caught when they can be <strong>known to be errors</strong> and where you have the most information. This varies between languages and implementations.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload