NCTU CIS: Programming Languages (Graduate, Spring 1998)

Course Information

Instructor

Wuu Yang, <wuuyang@cis.nctu.edu.tw>, EC332B, 03-5712121 ext. 56614.

Teaching Assistants

To be announced later.

Lectures

ED525, 1EF and 3B

Course URL

http://www.cis.nctu.edu.tw/~wuuyang/Lecture/lecture.pl.html

Course Description

  1. Parsing, structural induction, lattice framework
  2. Attribute grammars
  3. Post systems
  4. Lambda calculus, functional programming, and type checking
  5. Denotational semantics

In this course, we plan to discuss the design of programming languages and the implementation tools of programming languages. We start from the parsing of programming languages. In particular, we will discuss general parsing (for arbitrary context-free languages) and incremental parsing.

In the second part we will study attribute grammars, the definition, evaluation, evaluator generation, parallel and incremental evaluation. Attribute grammars are an important tool for compilers and practical tools for software development environments.

In the third part, we will study Post system. Post systems are a foundation of many formal systems, including type systems in programming languages.

In the fourth part of the course, we study functional programming. The topics include introduction, higher-order functions, polymorphic type checking, lazy evaluation, lambda calculus, and continuation.

In the last part, we will discuss denotational semantics of programming languages. If we have time at the end of the semester, the students will be asked to present papers.

The course material will be papers from journals and conference proceedings. We will offer you a reading list and a copy of original papers.

Reading List

The material for this course is taken from various journals and conference proceedings.
  1. Ryan Stansifer, The Study of Programming Languages, Prentice-Hall, 1995 (reference only, we will not follow the book chapter by chapter).
  2. J. Earley, An efficient context-free parsing algorithm, Communication of ACM, 13, 2, February 1970.
  3. Cocke, Younger, Kasami, CYK parsing algorithm (you can find this algorithm in Hopcroft and Ullman, Introduction to Automata Theory, Languages, and Computation, 1979.)
  4. C. Ghezzi and D. Mandrioli, Augmenting parsers to support incrementality, J. ACM, 27, 3, 1980, 564-579.
  5. H. Alblas, Introduction to attribute grammars, Proceedings of the International Summer School SAGA, (Prague, Czechoslovakia, June 1991), Lecture Notes in Computer Science 545, Springer-Verlag, 1991, 1-15.
  6. U. Kastens, Ordered attribute grammars, Acta Informatica, 13, 229-256, 1980.
  7. M. Jourdan, A survey of parallel attribute evaluation methods, LNCS 545, 234-255, 1991.
  8. T. Reps, T. Teitelbaum, A. Demers, Incremental context-dependent analysis for language-based editors, ACM Transactions on Programming Languages and Systems, 5, 3, 1983.
  9. K. Kennedy and S. Warren, Automatic generation of efficient evaluators for attribute grammars, Conference Record of the Third ACM Symposium on Principles of Programming Languages, (Atlanta, Ga., Jan. 19-21, 1976), January 1976, 32-49.
  10. Post Systems, in R. Stansifer, The Study of Programming Languages, 1995.
  11. P. Hudak and J.H. Fasel, A gentle introduction to Haskell, ACM SIGPLAN Notices, 27, 5, May 1992. (reference only)
  12. J. Hughes, Why functional programming matters, The Computer Journal, 32, 2, 1989.
  13. P. Wadler, The essence of functional programming, Conference Record of the Nineteenth ACM Symposium on Principles of Programming Languages, (Santa Fe, NM, January 13-15, 1992), January 1992, 1-14.
  14. L. Cardelli, Basic polymorphic typechecking, Science of Computer Programming, 8, 1978, 147-172.
  15. Milner, R., "A Theory of Type Polymorphism in Programming," J. of Computer and System Sciences, vol. 17, 348-375, 1978.
  16. L. Cardelli and P. Wegner, On understanding types, data abstraction, and polymorphism, ACM Computing Survey, 17, 4, December 1985.
  17. D. Scott, Data types as lattices, SIAM J. Computing, 5, 3, September 1976, 522-587.
  18. R.D. Tennent, The denotational semantics of programming languages, Communication of ACM, 19, 8, 1976.
  19. J.E. Stoy, Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory, MIT Press, 1977. (reference only)
  20. L. Allison, A Practical Introduction to Denotational Semantics, Cambridge U. Press, Cambridge, England, 1986. (reference only)

Grading (tentative)

There will be one project and two exams (tentatively).

Project: Simple-Minded Attribute-Grammar System

You are asked to implement an attribute-grammar system, including both the generator and the evaluator. Our attribute grammar is called the simple-minded AG (SMAG).

A sample SMAG is as follows:

This attribute grammar is called myFirstAG.
Put comments before %SYMBOL%
Blank lines may be inserted as you wish.

%SYMBOLS%
S(synthesized r);
X(inherited a, b; synthesized c);
Y(inherited d; synthesized e);
%RULES%
S ::= X
      { r = c +3;
        a = 3;
        b = 5; }
X ::= X Y Y
      { X@1.c = X@2.c + Y@1.e + Y@2.e;
        X@2.a = X@1.b + 1;
        X@2.b = X@2.a + 3;
        Y@1.d = X@1.a - X@1.b;
        Y@2.d = Y@1.e - X@2.c; }
X ::= Y
      { X.c = Y.e;
        Y.d = X.a - X.b; }
Y ::= "hello"
      { Y.e = Y.d + 6; }
Y ::= "good"
      { Y.e = 9 - Y.d; }
%END%
More comments may follow %END%

An SMAG contains two sections, denoted by the keywords %SYMBOLS%, %RULES%, and %END%.

SMAG ::== %SYMBOLS% SymbolSection %RULES% RuleSection %END%

All the nonterminal symbols and their attributes must be declared in the symbol section. The SMAG generator must check this requirement. The names of symbols and attributes consist of English letters and the digits and must begin with a letter. Upper and lower case letters are considered identical. The symbol section contains one or more symbol declaration.

SymbolSection ::== Declaration | Declaration SymbolSection

A declaration has a symbol followed by the declarations of its inherited attributes followed by its synthesized attributes.

Declaration ::== name ( [ inherited NameList ; ] [ synthesized NameList ] ) ;
NameList ::== name | name , Namelist

Note that inherited and synthesized are reserved keywords and the use of the three punctuation symbols ( ; ).

The rule section contains one or more rules.

RuleSection ::== Rule | Rule RuleSection

Each rule consists of a symbol, the derivation symbol ::=, zero or more symbols or constants, and a set of zero or more attribution rules. A constant is anything enclosed within a pair of double quotes.

Rule ::== name ::= NameConstList '{' AttRules '}'
NameConstList ::= | NameConst | NameConst NameConstList
NameConst ::== name | constant
AttRules ::== | AttRule | AttRule AttRules

An attribution rule consists of an attribute occurrence, an equal sign =, and an expression.

AttRule ::== Att = Exp ;

An attribute occurrence has the form name.name or name@integer.name. The first name denotes a symbol in the rule. The second name denotes an attribute of the symbol. When there are more than one occurrence of a symbol, they are numbered from left to right with integers, and these symbols are appended with an integer.

Att ::== name . name | name @ integer . name

An expression has the form of usual arithmetic notations and consists of attributes occurrences, positive integer constants, addition sign +, and subtraction sign -. There are no parentheses nor other operators. Evaluation of an expression proceeds from left to right. Though we use much simplied expressions, you should design your programs so that it is very easy to modify in order to manipulate complex expressions.

Exp ::== AttInt | AttInt + Exp | AttInt - Exp
AttInt ::== Att | integer

In this project, you are asked to implement a plan generator, a lexical analyzer of the target language, a context-free-grammar parser of the target language, and an evaluator. The plan generator generates plans for an SMAG and it must also check that an input SMAG is in the correct form and it is an ordered attribute grammar. The evaluation system parses an input sentence with the help of the lexical analyzer and the parser of the target language, evaluates the attributes and, finally, prints the values of all the attributes of the start symbol in a readable format.


Local On-Line Information

Information on the Net


Wuu Yang, <wuuyang@cis.nctu.edu.tw>, EC332B, 03-5712121 ext. 56614.