Ask Question
13 May, 06:05

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

+3
Answers (1)
  1. 13 May, 09:35
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers