Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Y ou w rite this The com puter translates...itinto this, w hich it can run
How it is done?
The compiler takes the file that we
have written translates it and produces
another file from it.
For example in the case of Pascal
programs, we might write a program called
myProg.pas and the Pascal compiler
would translate it into the file myProg.exe
which we could run.
Compilers also checks the program to
make sure that it is grammatically correct. Only
when it is sure that there are no grammatical
errors does it do the translation.
If there is any error (compile-time errors or
syntax errors) compiler generates an error
message and is displayed on the screen. Only
after correcting all the errors the compiler
create the object code.
Stages of processing
Tokenising Syntax analysis Semantic
analysis Translation
Tokenising:- Also known as lexical
analysis. It involves turning the program
from a series of characters into a series of
tokens that represent the building blocks of
a program and reports it to the next stage
of the process . The tokens are keywords
of the language i.e. important words such
as if, print or repeat, variable names and
mathematical operators (+, *, brackets
etc.).
Syntax analysis :- The syntax analyser in
a compiler checks that the right tokens
appear in the right order to make
grammatically correct instructions
Semantic Analysis :- The semantic
analyser checks the meaning of the
program. It checks variable declarations
and scope, whether the program has
entered or left loops, or subroutines, etc.
The final stage is generating machine
code.
Interpreter