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...
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...
Errors in the program evaluation process can occur at any stage and can potentially have disastrous...
Errors in the program evaluation process can occur at any stage and can potentially have disastrous effects on the acceptance or proper interpretation of the results. These errors encompass many areas including, but not limited to relationships, logic, scapegoating, and population masking. For this discussion, respond to the following: Analyze which errors have the most damaging impact on an evaluation. Provide clear examples to support your perspective from your experiences, course materials, or your own research. Use APA formatting to...
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...
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?
Forecasting can be classified into four basic types: Qualitative, Time series, Causal relationship, and simulation. Determine...
Forecasting can be classified into four basic types: Qualitative, Time series, Causal relationship, and simulation. Determine which one or two styles best fits an electrical distribution companies forecast needs. Why?
Detect the errors in the following program? How many errors do you observe in the following...
Detect the errors in the following program? How many errors do you observe in the following line of code? Clearly explain what these errors are and how they can be fixed? (Note that this program has only three lines of code). Please type your program in the following textbox. for i in Range(1,20.0): if i%2=0: print(i) This is a python program
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT