Você está na página 1de 3

ntroduction

PASCAL is a programming language named after the 17th century mathematican Blaise
Pascal. Pascal : provides a teaching language that highlights concepts common to all
computer languages, in other words once you learn PASCAL most other programming
languages are very similar. standardises the language in such a way that it makes
programs easy to write

History
Turbo Pascal is a popular version of Pascal, made by Borland/Inprise
Inc. Pascal was originally designed for teaching and it still is. It is
mostly used to teach students, but it has a built-in Assembler so its
power can't be overlooked. Most people don't like it is that all its
commands are words, so much typing! Anyway, it's a very good language
to learn. It's structural, good for future careers in programming.

Pascal and C Language


Both C and Pascal are considered High Level Languages. They use English
type statements that are converted to machine statements which are
executed by computers.
C and Pascal programs are simple text files containing program
statements. As such, they are created using a text editor. This is
called the source program

Pascal Compiler

A computer cannot understand the spoken or written language that we humans use in our
day to day conversations, and likewise, we cannot understand the binary language that
the computer uses to do it's tasks. It is therefore necessary for us to write instructions in
some specially defined language, in this case Pascal, which we can understand, then have
that very precise language converted into the very terse language that the computer can
understand. This is the job of the compiler

A Pascal compiler is itself a computer program who's only job is to convert the Pascal
program from our form to a form the computer can read and execute. The computer
prefers a string of 1's and 0's that mean very little to us, but can be very quickly and
accurately understood by the computer. The original Pascal program is called the "source
code", and the resulting compiled code produced by the compiler is usually called an
"object file".

One or more object files are combined with predefined libraries by a linker, sometimes
called a binder, to produce the final complete file that can be executed by the computer.
A library is a collection of pre-compiled "object code" that provides operations that are
done repeatedly by many computer programs.

Program Structure
The basic structure of a Pascal program is:

PROGRAM ProgramName (FileList);


CONST (* Constant declarations *)
TYPE (* Type declarations *)
VAR (* Variable declarations *) (* Subprogram definitions *)
BEGIN (* Executable statements *)
END.

The elements of a program must be in the correct order, though some may be omitted if
not needed. Here's a program that does nothing, but has all the REQUIRED elements:
program DoNothing;
begin
end.

program first;
begin
(*comment*)
end.

1. program first; - is the "program header". Program headers are for dealing with
multiple programs and "units". For most dialects this is optional.
2. begin - tells the complier where the program begins. In more complex programs
this statement might be preceded by statements that declare variables, set up
functions and handle other preparation before the main program begins.
3. (*comment*) - is a comment that is ignored by the complier. The (* and *) tell
the compiler to ignore what's in between them, almost all dialects of pascal also
use braces ( { and } for the same purpose. In the original Pascal, these can't be
embedded like this: (*(*example*)*). However, in almost all dialects that use
braces also use precedence, so this works: {(*example*)}. In some dialects such
as Free Pascal's default mode comments can be embedded.
4. end. - (notice the period) tells the compiler to stop compiling. In fact, anything
after that is completely ignored. As we shall see, there may be many begin and
end statements in a program, but the end statement that terminates the program is
the only statement that ends in a period.

program HelloWorld;
begin (*This is were the program begins*)
writeln('Hello world!');
end. {This is where the program ends.}

Você também pode gostar