Ask Question
11 April, 08:44

Errors in a computer program can be classified according to when they are detected and, if they are detected at compile time, what part of the compiler detects them. Using your favorite imperative language, give an example of each of the following. a. A lexical error, detected by the scannerb. A syntax error, detected by the parserc. A static semantic error, detected by semantic analysisd. A dynamic semantic error, detected by code generated by the compilere. An error that the compiler can neither catch nor easily generate code to catch (this should be a violation of the language definition, not just a program bug) (Use the same language for parts (a) - (d). You may use a different language for part (e) - - this part could be challenging in Java, for example.)

+2
Answers (1)
  1. 11 April, 11:26
    0
    The chosen language in this instance is Java. The errors are explained below

    Explanation:

    a. Lexical error, detected by the scanner: 'aa' is the string and not the character so 'a' will not be assigned the data type char.

    b. Syntax error: Missing '; ' at the end of a statement.

    c. A static semantic error, detected by semantic analysis: arr[10.5], the array will become out of bounds.

    d. A dynamic semantic error, detected by code generated by the compiler:

    int [] array = new int [10];

    array [10] = 0;

    The array here, has been assigned value 0 which is not with in the bounds.

    e. An error that the compiler can neither catch nor easily generate code to catch (this should be a violation of the language definition, not just a program bug:

    int a;

    if (false)

    {

    x = 10;

    system. out. println ("Error");

    }

    Here, the value of x is unreachable, yet error will not be reported.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Errors in a computer program can be classified according to when they are detected and, if they are detected at compile time, what part of ...” 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