The Heart Of A Compiler
The Heart Of A Compiler
Written by Mike James   
Wednesday, 20 February 2013
Article Index
The Heart Of A Compiler
Formula translation
A Solution

Fortran at last!

This order of evaluation problem was what faced the IBM team who had been assembled (no pun intended) to make the assault on computer science’s equivalent of getting a man on the moon - the automatic translation of arithmetic expressions.

The team, under the leadership of John Backus, was to construct a compiler for a computer language that could compile any arithmetic expression that a programmer cared to throw at it.

To do this they had to invent a way of writing down and making use of the rules of grammar for artificial languages such as programming languages and mathematical expressions. They invented the production rules as described above and a method of using the rules to parse the language and generate the correct assembly code.

The trick is to convert the expression into a syntax tree which makes clear the relationships between the operators and their priorities. Once you have the syntax tree then you can use it to generate the operations in the correct order by simply "walking" the tree.  For a more detailed explanation see: Grammar and Torture.

The six-month project actually took two years before the first compiler was available in 1956 and it took until April 1957 before working compilers were distributed to customers. It consisted of 25,000 lines of machine code on a magnetic tape and it was distributed, complete with bugs, to every IBM 704 installation.

The language was called FORTRAN standing for FORmula TRANslation and when they finally got it to work it revolutionized programming and made IBM the number one computer company for decades.

Notice that the name of the language was derived from FORMula TRANslation. Even though the language had lots of other new features it was the fact that it could successfully convert an arbitrary arithmetic expression or formula into machine code that was its great claim to fame. Once you work out how to do this particular job the rest of the compiler was a matter of comparatively simple book keeping.


Related Articles

Assemblers and assembly language

Grammar and Torture

John Backus - the Father of Fortran

Brackets are Trees


Computer Memory and Pigeonholes


How Memory Works

Inside the Computer - Addressing

Inside the processor


The Essence Of Programming

Variables revisited


To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.






or email your comment to:


Binary Arithmetic

What could be simpler than binary arithmetic? It’s just two-fingered counting and, once you know how it works, it seems natural for a computer to use it. But decimal is so built into our hands that  [ ... ]

Binary - Negative Numbers

Binary arithmetic is easy, so easy a computer can do it, but what about negative numbers? This is altogether more tricky and isn't just a matter of putting a negative sign in front of the number.

Other Articles





Last Updated ( Thursday, 21 February 2013 )

RSS feed of all content
I Programmer - full contents
Copyright © 2018 All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.