A89: compilers


[Prev][Next][Index][Thread]

A89: compilers




Lynn McCartney writes:
 > Could some one please tell me what a compiler does exactly?  I would greatly appreciatte the help I get.  Thanks for your trouble.

A compiler is a program that translates a program expressed in some
computer language into an other, usually simpler computer language.

In this regards a computer language is mostly anything that can
describe operations done by a computer. In addition, computer
languages are usually context free (for computers and mathematics in
general have very limited capabilities in the context-dependent
field).

Your C compiler, for example, reads a source written in the C language 
and generates either assembly language output or direct object code.

An interesting exception is that the compiler from assembly language
(which is the human-readable machine language language closest to 
machine code, i.e. numbers) is invariably called an assembler.

Often compilers are used in succession to compile something that's
complex or fairly abstract to machine code. The C language belongs to
the high-level languages, but it is one of the lowest level in that
group. It is often the case that a higher level high-level language is 
compiled to C, then it is compiled to assembly then it is assembled to 
machine code.

There are even trickier things, like yacc (standing for yet another
compiler compiler) which is a compiler that compiles the yacc language 
to C. The yacc language is a language designed to describe the parsing 
part of compilers. So when you define a language, you describe the
language in yacc and tell yacc how to generate various say FORTRAN
constructs from your language. Yacc then generates a C code, you
compile it and then you get a program which is a compiler that can 
reads programs written in your language and translates them to FORTRAN 
which you then can compile to assembly then machine code. There are
much hairier scenarios sometimes. Mind boggling, isn't it :-)

On a different note, it is generally accepted as a polite and
intelligent behaviour on the Net not to use HTML or any format 
other than ASCII in email, mailing lists and USENET postings
and to turn on word wrap at around 72-76 characters.

Regards,

Zoltan


Follow-Ups: References: