Ask Question
11 April, 03:21

Using your favorite imperative language, give an example of each of the following. (a) A lexical error, detected by the scanner (b) A syntax error, detected by the parser (c) A static semantic error, detected by semantic analysis (d) A dynamic semantic error, detected by code generated by the compiler

+4
Answers (1)
  1. 11 April, 04:09
    0
    a. int foo+; (foo + is an invalid identifier because + is not a valid char in identifiers)

    b. foo int; (Syntax error is any error where the syntax is invalid - either due to misplacement of words, bad spelling, missing semicolons etc.)

    c. Static semantic error are logical errors. for e. g passing float as index of an array - arr[1.5] should be a SSE.

    d. I think exceptions like NullReferenceException might be an example of DME. Not completely sure but in covariant returns that raise an exception at compile time (in some languages) might also come in this category. Also, passing the wrong type of object in another object (like passing a Cat in a Person object at runtime might qualify for DME.) Simplest example would be trying to access an index that is out of bounds of the array.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Using your favorite imperative language, give an example of each of the following. (a) A lexical error, detected by the scanner (b) A ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers