Académique Documents
Professionnel Documents
Culture Documents
rktiwary
The following exercises use the simulator’s inbuilt
compiler. Click on the COMPILER… button to show
the compiler window.
Enter the following source code
program Ex1
n = 5
for i = 1 to 6
n = n + 1
if n = 3 then
n = 0
end if
next
end
1. What are the Pass 1, Pass 2 and Pass 3 stages called? Briefly
explain the function of each stage based on your observations
Pass1:
Tokenizing source statements (Lexical Analysis)
Lexical analysis is the first phase of a compiler. It takes the
modified source code from language preprocessors that are
written in the form of sentences. The lexical analyzer breaks
these syntaxes into a series of tokens, by removing any
whitespace or comments in the source code.
program Ex1 n = 5 for i = 1 to 6 n = n + 1 if n = 3 then n = 0 end if next end
Pass2:
Constructing the symbol table
Pass 3