17.01.2015 Views

Course Notes on Formal Languages and Compilers

Course Notes on Formal Languages and Compilers

Course Notes on Formal Languages and Compilers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

49<br />

9. PROGRAMMING LANGUAGE DESIGN AIMS<br />

5<br />

10<br />

15<br />

20<br />

25<br />

1) It should not be difficult to write programs which are easy for any<strong>on</strong>e<br />

to underst<strong>and</strong>.<br />

2) It should not be difficult to write programs to solve the problems you<br />

need to solve.<br />

3) Effective methods should be available for defining the syntax <strong>and</strong><br />

semantics of programming languages.<br />

4) Efficient algorithms should be available for recognizing legal<br />

programs.<br />

5) Programs should be easy to translate to any machine language.<br />

6) The translated programs should run efficiently.<br />

7) Preferably programming errors should be prevented or easily<br />

detected <strong>and</strong> corrected.<br />

However, programming is hard <strong>and</strong> designing <strong>and</strong> implementing<br />

programming languages is very much harder. N<strong>on</strong>etheless, there has been<br />

progress in achieving these aims.<br />

Class discussi<strong>on</strong>: Which of these aims are important to the programmer, his<br />

supervisor, the language designer, the writer of a compiler or interpreter, a<br />

computer manufacturer, a software producer Give examples illustrating<br />

some design aims.<br />

Exercise: In ADA the index of a FOR loop is a local variable of the loop.<br />

What advantages does this give to the compiler writer<br />

The definiti<strong>on</strong> of programming languages<br />

30<br />

35<br />

40<br />

Syntax: The syntax of assembly languages (except for expressi<strong>on</strong>s) can be<br />

defined by a regular expressi<strong>on</strong> or grammar. However, for high level<br />

languages c<strong>on</strong>text free grammars are needed, but are not fully adequate.<br />

So additi<strong>on</strong>al restricti<strong>on</strong>s c<strong>on</strong>cerning the form of a legal program are defined<br />

in natural language (English).<br />

Semantics: In practice the meaning of the program is defined in natural<br />

language (English). The following formal (mathematical) methods have<br />

been proposed but are rarely used in practice.<br />

1) Translati<strong>on</strong>al Semantics 2) Operati<strong>on</strong>al semantics<br />

3) Axiomatic definiti<strong>on</strong> 4) Extensible definiti<strong>on</strong><br />

5) Mathematical or Denotati<strong>on</strong>al semantics

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!