1.4 Theoretical Viewpoint

Before we go ahead with knowing more details about a compiler, it is worthwhile to know what the formal language and automata theory have to say about a compiler. A more substantial account is given in Appendix A, but here we have bare minimum.

1.4.1 Acceptor and Compiler

In formal language theory, a compiler is simply an acceptor, which reads input strings and outputs “Yes” or “No”, depending upon whether a string is in language L1 or not (see Fig. 1.10).

 

Compiler as an acceptor

 

Fig. 1.10 Compiler as an acceptor

 

A compiler is useless if it does not point out errors. (Yes, but which errors?) A real compiler does this by typing out errors! It also translates from L1 to L2, but the acceptance function is still the most important. What will you do with a program which is not correct according to the syntax of the source language?

It tells you whether your program adheres STRICTLY to the rules of a particular language. These rules are given as a grammar and a compiler represents this grammar.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.75.70