CSCI 4627
Spring 2003

Last modified: 3/25/03

Announcements

Please turn in your final compiler using handin as assignment 5. Turn in ALL files that are part of your work. Additionally, turn in a file called README that briefly summarizes how much of the language you believe your compiler correctly implements. If your files are parser.c, symtbl.c, symtbl.h and README, then you can hand them in using the following command.
  /export/stu/classes/csci4627/bin/handin csci4627 5 parser.c symtbl.c symtbl.h README

An attribute-grammar-based compiler for C- is available.

Your next assignment was discussed in class. Implement the subset of C- that allows

Translate that subset into the language of the abstract machine described in the following files.

An implementation of the abstract machine, along with an assembler and a disassembler, will be made available in the near future.


Syllabus

See the syllabus for a description of the course.


Manuals


Assignments

Please see the checklist for writing and turning in programs.

General homework

  1. Hand crafted lexer
  2. Written homework due Jan 29

Compiler project

  1. Lexer (due Feb 5)

Practice exams

  1. Practice questions for exam 1
  2. Answers to practice questions for exam 1
  3. Practice questions for exam 2
  4. Answers to practice questions for exam 2


Systems

Using Solaris

A short tutorial on Solaris is available.

Secure shell

You can get to the lab computers using ssh and sftp. Machines that allow ssh access are atlantic.cs.ecu.edu and others on the back row in room 320.

Ssh for Windows is available from ftp://ftp.ssh.com/pub/ssh. Get SSHSecureShellClient-xxx.exe. It is a self-extracting executable. Just run it and it will install itself.


Lecture summaries

  1. [1/8/03] We went over the syllabus, and then looked at what compilers do and at the large-scale anatomy of a compiler.

  2. [1/13/03] We began looking at lexical analysis. A lexer takes a sequence of characters and produces a sequence of tokens (additionally attaching an attribute to some tokens). One way to write a lexer is to take an ad-hoc approach, using general-purpose programming methods. That turns out to be the worst way to do it. A much better approach is to draw a finite state machine that describes how the lexer should compute, and to translate the finite state machine directly to a program. An even better idea is to let somebody else (a machine) do the translation for you. We began to look at describing lexers using regular expressions.

  3. [1/15/03] We continued to look at lexers. We went over finite state machines, and at how to use flex to produce lexers automatically.

  4. [1/20/03] Holiday.

  5. [1/21/03] (This Tuesday is a Monday.) We started looking at syntactic analysis by looking at syntax trees and parse trees, and methods of producing them from sequences of tokens. We introduced context-free grammars as a way of describing allowed structures of parse trees. Context-free grammars, syntax trees and parse trees are covered in Chapter 3 of the text.

  6. [1/22/03] We continued looking at syntactic analysis, and introduced top-down predictive parsing. Some grammars make predictions possible by looking only at the next token, while others require more sophisticated prediction algorithms. Some grammars are ambiguous, which is the other extreme. Not only do they not tell how to make predictions, but they do not even define the problem of determining the parse tree uniquely. There are other grammars that are in between. They describe a well-defined parsing problem, but they do not admit simple prediction algorithms. We will concentrate on grammars that allow for a very simple prediction scheme. A grammar that has a simple prediction scheme can be turned into a parser using the method of recursive descent, where there is a function for each nonterminal in the grammar. Recursive descent parsers are covered in Chapter 4 of the text.

  7. [1/27/03] We discussed transformations on grammars that make predictive parsing possible, and produce an example of a recursive-descent parser.

  8. [1/29/03 - 2/27/03] Not documented lecture by lecture, but we covered the following topics.

    Computing First and Follow sets. Building LL(1) parse tables, and LL(1) parsers.

    Bottom-up parsing. Shift-reduce parsers. Building SLR(1) parser tables.

    Syntax-directed translation. Imperative model of translation. Functional model of translation.

    Attributes and attribute grammar. Synthesized and inherited attributes.

    Ideas for translating C- to a stack-based abstract machine.

  9. [3/3/02-3/7/03] Spring break

  10. [3/10/03] We went over examples using synthesized and inherited attributes.

  11. [3/12/03] We looked at how to generate code for C- expressions for a stack-based machine.