Skip to main content

Posts

Showing posts with the label Compiler Design

Compiler Construction Tools

The compiler writer, like any software developer, can profitably use modern software development environments containing tools such as language editors, debuggers, version managers, profilers, test harnesses, and so on. In addition to these general software-development tools, other more specialized tools have been created to help implement various phases of a compiler. The most successful tools are those that hide the details of the generation algorithm and produce components that can be easily integrated into the remainder of the compiler. Some commonly used compiler-construction tools include: 1. Parser generators that automatically produce syntax analyzers from a grammatical description of a programming language. 2.   Scanner generators that produce lexical analyzers from a regular-expression description of the tokens of a language. 3. Syntax-directed translation engines that produce collections of routines for walking a parse tree and generating intermedia...

Assemblers and Interpreters

Assemblers In the early days of programming, machine code (binary) was the only option. Unfortunately this was laborious, prone to error and difficult. A slight improvement on this was the use of hexadecimal or octal which reduced the number of errors and the time to enter the program. Eventually assembly languages were developed which were easier and more productive to use whilst preserving the speed and compactness of machine code. Assembly languages vary from one type of computer to another (or more correctly from processor to processor) which results in a difficulty in transporting programs from one computer to another.   Assemblers are the simplest of all the translators to understand since the majority of the statements in the source code are mnemonics (short words that help you to remember something) representing specific binary patterns - the others being labels, directives (or pseudo-ops) which give instructions to the assembler.   So, for insta...

Introduction to Compilers

Compilers and Translators If you are unable to speak French and yet wish to communicate a French speaker then you need someone to translate English into French. The same happens with computers languages. We would like to communicate in English but the computer only understands binary - so a translator is required. Thus the basic function of a translator is to convert a SOURCE (or original) program into an Object (or binary) program. There are three main categories of translator: Assemblers, Interpreters and Compilers. Under normal circumstances (ie unless great speed or compactness is required) the source program will be written in a high level language which is either interpreted or compiled. A translator can be defined as: “ A device that changes a sentence from one language to another without change of meaning.”