AFP2004

Ehc

AG material

  • Slides of the preschool AG tutorial.
  • AG manual.
  • Paper and slides of "Typing Haskell with an Attribute Grammar". The paper will appear in the proceedings in a corrected and adapted form.

EH compilers

The set of compilers is described during the AFP 2004 summerschool.

  • The set of compiler version which is consistent with the distributed paper can be downloaded here. Each compiler resides in its own directory with a Makefile. Just type 'make' to create a compiler.
  • Sources of the EH programs used as an example in the paper: test.tgz
  • For installation on your own machine you need to install the UUST library. Currently no prebuild installations exist but the library can be cvs'd:
    % cvs -d :pserver:anonymous@cvs.cs.uu.nl:/data/cvs-rep login
    % cvs -d :pserver:anonymous@cvs.cs.uu.nl:/data/cvs-rep checkout uust
          
    • The file INSTALL.html contains the install instructions:
      % ./configure
      % make
      % sudo make install
            
    • The configure/build process assumes the presence of Hugs. This has not yet been fixed.

Lab exercises

Exercise 1: Extending the html example from the preschool presentation

The AG file Main.ag implements the html generation from the preschool tutorial. It produces (for test nr 5) the output found here.

  1. Make a mistake in the input file, and notice how the parser combinators that are being used inside AG try to correct your input.
  2. Comment out the largest part of the file, and inspect the generated code. Pay especially attention to the automatically generated copy rules.
  3. Adapt Main.ag so that it creates a html file with prev/next links, as the example output here shows.
  4. Extend the html generation further with an up/down button. The up button leads to a section one level higher, if present. The down button leads to the first subsection of a section, if present.

Compile and run the given Main.ag by

% uuagc -a Main.ag
% ghc -package uust --make -o html Main.hs
% ./html 5
The compilation requires the uust library (see EH compilers for installation instructions) which is installed on all Unix lab machines.

Exercise 2: Pretty printing

The file Slides.ag is the starting point of this exercise. It was constructed out of the text of the Pretty Printing paper (with a few small corrections with respect to the paper version).

  1. Change the attribute grammar so it will never put more than ribbon width data on a line. This is to avoid unpleasingly long lines.
  2. Check the functionality by experimenting with the width w.
  3. Add the possibility to add vertical composition, in which you can place text elements in a stacked way.

Compilation and running is similar to the previous exercise.

-- AtzeDijkstra - 19 Aug 2004