Ask Question

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. 11 May, 14: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?
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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers