Question

In: Computer Science

- In general, the occurrence of errors (errors) in a program can be classified in four...

- In general, the occurrence of errors (errors) in a program can be classified in four categories. List and explain, then give an example, of each mistake (error)!

and also

- It is known that: S -> aB | bA A -> a | aS | bAA B -> b | bS | aBB Derivation for the string aaabbabbba Provide a solution for its derivation and syntax analysis.

Please explain it with easy understandable method, because im still in learning phase :). Thanks in advance.

COURSE : Compilation Techniques

Solutions

Expert Solution

The types of errors are classified into 4 categories.

1. Syntax errors

2. Run-time errors

3. Logical errors

4. Latent errors

1. Syntax Errors

Every programming language has different syntax. You have to follow the syntax to successfully compile the program. A syntax error is an error in the source code of a program. If syntax of the program is not correct then compiler gives syntax error. Any violation of rules of programming language results in syntax errors. Syntax error depends on the programming language.

Example: In c , c++ or java if you forgot to put semicolon(;) then it gives error. while in python it gives no error because semicolon is not required in python syntax.

Below is the example of syntax error in c language.

In python if you forgot to put semicolon then it does't give error. See the below example.

So syntax error is totally depends on which programming language you choose.

2. Run-time Errors

Runtime errors are the errors that occur during the execution of the program, after successfully compiling the program. Program successfully compiled so no syntax error is present. Example of runtime error is dividing by zero error. These are not detected by compiler while compilation process. It is difficult to detect and remove runtime errors.

3. Logical Errors

Logical errors are related to the logic of the program. Logical errors are not detected by compiler and cause incorrect results. while executing program expected output is not come and some random output occurs.

In below code for loop runs five times so it should print

Count: 1
Count: 2
Count: 3
Count: 4
Count: 5

but semicolon after for loop is logical error, so it prints only one time.

Correct code after removing logical error shold print like below.

4. Latent Errors

Latent Errors occur only when specific type of data is used.

result = (x * y) / z ;

An error occurs only when z is equal to 0 because that will make remainder zero otherwise it gives correct output. Such errors can be detected only by using all possible combinations of data.

Below is the code when z = 0 so it gives error.

Below is the code when z is not zero. So it gives correct output.


Related Solutions

Develop an onboarding program for an organization. This program can be general to the organization, or...
Develop an onboarding program for an organization. This program can be general to the organization, or can be for a specific area, and for brand new employees or those transferring/promoted who are new to an area of the organization Brief explanation, and identify the intended recipients of the program Identify the components of a socialization program that will be ideal for your onboarding program. Be sure to keep in mind the following items: Stage Models of Socialization The Information Newcomers...
Write a program to detect the deadlock occurrence and write the sequence if there is a...
Write a program to detect the deadlock occurrence and write the sequence if there is a safe state. Noted: C or C++
There are at least 10 errors in the following C program. For each error you can...
There are at least 10 errors in the following C program. For each error you can find you should list the location of the error, describe what the error is, and state how the error can be fixed (write updated code for that line if necessary). Each error you find is worth 1.5 marks. Note that missing brackets, braces, etc count as only one error, even though the missing brackets may occur at two places. The program is supposed to...
There are at least 10 errors in the following C program. For each error you can...
There are at least 10 errors in the following C program. For each error you can find you should list the location of the error, describe what the error is, and state how the error can be fixed (write updated code for that line if necessary). Each error you find is worth 1.5 marks. Note that missing brackets, braces, etc count as only one error, even though the missing brackets may occur at two places. The program is supposed to...
There are at least 10 errors in the following C program. For each error you can...
There are at least 10 errors in the following C program. For each error you can find you should list the location of the error, describe what the error is, and state how the error can be fixed (write updated code for that line if necessary). Each error you find is worth 1.5 marks. Note that missing brackets, braces, etc count as only one error, even though the missing brackets may occur at two places. The program is supposed to...
All cars can be classified into one of four? groups: the? subcompact, the? compact, the?midsize, and...
All cars can be classified into one of four? groups: the? subcompact, the? compact, the?midsize, and the? full-size. There are five cars in each group. Head injury data? (in hic) for the dummies in the? driver's seat are listed below. Use a 0.05 significance level. Find the? P-value to test the null hypothesis that the different weight categories have the same mean. Do the sample data suggest that larger cars are? safer? Subcompact   Compact   Midsize   Full-size 681   643   469   384...
How does epigenetics relate to decision making and occurrence of type 1 and type 2 errors...
How does epigenetics relate to decision making and occurrence of type 1 and type 2 errors in the diagnostic process in a therapeuitc setting?
About errors that can occur in the process of meiosis, and several types of errors are...
About errors that can occur in the process of meiosis, and several types of errors are mentioned. Select of these types of errors (e.g. chromosome number, non-disjunctions, etc.) and provide a brief description of the error. Then do a little bit of online research related to the type of error and identify and describe one disease or condition that can result from this type of error (example – Trisomy 21 is where there is an extra chromosome in the 21st...
Auditors can be classified under four types: (1) external auditors, (2) internal auditors, (3) government auditors,...
Auditors can be classified under four types: (1) external auditors, (2) internal auditors, (3) government auditors, and (4) forensic auditors. Explain?
The occurrence of unplanned shutdown in a manufacturing industry can be considered as a Poisson process....
The occurrence of unplanned shutdown in a manufacturing industry can be considered as a Poisson process. On average, eight shutdown occurs per year. (a) Calculate the probability that • the first shutdown occurs during the first quarter; • more than one shutdown occurs during the first half of the year. (b) Calculate the conditional probability that the second shutdown will occur during the first half of the year if the first shutdown occurred during the first quarter of the year.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT