Compiler error reporting

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Compiler error reporting

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A compiler finds errors in a program. When does it show the errors?
A After it has checked the whole program, as one list
B It stops and shows only the first error, then waits
2. A student compiles a program with 4 errors. What does the compiler report show?
A All the errors listed together
B Only one error at a time
3. A compiler finds a syntax error on line 12. What is NOT produced?
A The error report
B The executable file
4. A program has errors. Can the student run it straight after compiling?
A Yes, it runs up to the first error
B No, the errors must be fixed first
5. Which information does a compiler error report usually give?
A The line number and the type of each error
B Only the total number of lines in the program

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Compiler error report: line 3 syntax error, line 9 syntax error, line 14 undeclared variable AErrors found: line 2, line 5, line 11, line 20
2Compilation failed: 3 errors found. No executable file created. BLine 7: syntax error - missing closing bracket
3The error report shows the line number and the type of each error, so the programmer knows where to look and what is wrong CThe compiler checks the whole program and lists all the errors it found together, each with a line number and an error type
4A compiler reports all the errors from the whole program together, so the programmer can fix many errors before compiling again DThe compiler found errors, so it does not produce an executable and the program cannot be run until the errors are fixed
5The compiler finds an error on line 4, stops, and shows only that one error. The program then runs the lines before it. EIf a compiler finds errors, no executable file is created, so the program cannot run until all the errors are fixed and it is compiled again.
6Compiler: 2 errors found. Executable file created. Program starts running. FA compiler does not stop at the first error or run part of the program. It checks the whole code, lists all the errors, and nothing runs.

Definitions

compiler error report

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Compiler checks the _____ program first, then lists all errors together in a report.
2.
Errors found: 3 Executable file created: __
3.
Line 12: ______ error: missing bracket
4.
5 total = 10 + Error report: line _ - incomplete sum
5.
IF errors _ 0 THEN OUTPUT "No executable - fix errors"

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A errors ← CHECK_WHOLE(program)
B IF errors > 0 THEN
C OUTPUT report
D executable ← CREATE(program)
E ENDIF
Question 2
A report ← EMPTY LIST
B FOR EACH err IN allErrors
C ADD err TO report; STOP
D NEXT err
E OUTPUT report
Question 3
A Running shop.c ...
B Line 4: syntax error
C Line 9: undeclared variable
D 2 errors. No executable made.
Question 4
A FOR EACH err IN report
B OUTPUT err.line
C OUTPUT err.time
D NEXT err
Question 5
A count ← 0
B FOR EACH err IN firstError
C count ← count + 1
D NEXT err
E OUTPUT count, " errors found"

Answer Key

Compiler error reporting
Section A: Quick Questions
Q1
A — After it has checked the whole program, as one list
Q2
A — All the errors listed together
Q3
B — The executable file
Q4
B — No, the errors must be fixed first
Q5
A — The line number and the type of each error
Section B: Match the Pairs
Q1
Compiler error report: line 3 syntax error, line 9 syntax error, line 14 undeclared variable → The compiler checks the whole program and lists all the errors it found together, each with a line number and an error type
Q2
Compilation failed: 3 errors found. No executable file created. → The compiler found errors, so it does not produce an executable and the program cannot be run until the errors are fixed
Q3
The error report shows the line number and the type of each error, so the programmer knows where to look and what is wrong → Line 7: syntax error - missing closing bracket
Q4
A compiler reports all the errors from the whole program together, so the programmer can fix many errors before compiling again → Errors found: line 2, line 5, line 11, line 20
Q5
The compiler finds an error on line 4, stops, and shows only that one error. The program then runs the lines before it. → A compiler does not stop at the first error or run part of the program. It checks the whole code, lists all the errors, and nothing runs.
Q6
Compiler: 2 errors found. Executable file created. Program starts running. → If a compiler finds errors, no executable file is created, so the program cannot run until all the errors are fixed and it is compiled again.
Section C: Definitions
Q1
compiler error report — A list of every error found after the compiler checks the whole program, with line numbers and error types. No executable is made and nothing runs until all are fixed.
Section D: Fill in the Blanks
Q1
Compiler checks the whole program first, then lists all errors together in a report.
Q2
Errors found: 3 Executable file created: no
Q3
Line 12: Syntax error: missing bracket
Q4
5 total = 10 + Error report: line 5 - incomplete sum
Q5
IF errors > 0 THEN OUTPUT "No executable - fix errors"
Section E: Spot the Error
Q1
D — If the compiler finds errors it must not produce an executable file. Line 4 should set executable ← NONE, not create one.
Q2
C — A compiler does not stop at the first error. It keeps going and lists every error in the report, so the STOP should be removed.
Q3
A — A compiler translates the whole program first. It does not run it. The first line should say Compiling shop.c ... and not Running.
Q4
C — Each entry in a compiler error report shows the line number and the type of error. Line 3 should output err.type, not a time.
Q5
B — The compiler checks the whole program and reports all the errors together. The loop must go through allErrors, not just the first error.