CS 550 - Advanced Design and Translation of Programming Languages

Fall 2003

Bob Wall



(This page is also one of the class assignments.)


XML Grammar Files

Here are some files containing grammars to be used for testing most of the programming assignments - they are all in the XML format described in class. Micro is a particularly good test for the LL(1) table construction, because we were given the results in a handout. g3 is good for testing the CFSM construction, because the results for it are in the Fischer/LeBlanc book (Crafting a Compiler with C).

grammar1.xml An ambigous grammar for expressions
grammar2.xml An LR(1) version of the expression grammar
grammar3.xml An LL(1) version of the expression grammar
micro.xml Grammar for a subset of Pascal.
g3.xml Example grammar from Chapter 6 of Fischer/Leblanc book



Parsing XML

This is the source for a little program to test the expat parsing library. This is a SAX-model XML parser that is available for Linux (and has probably been ported to other platforms). It is a handy parser for simple XML input - you have to do some work yourself to keep track of things, but it's quick and easy.

    expat_parse.c



Source code and results for Assignments

Now to the crux of the matter - the source code for the assignments, and some results of running the programs on the test grammars.

First assignment - greedy scanner for Ada identifiers.
assignment1.htm Assignment description
Notes.html Implementation notes about the first program.
assgn1.c Source code for simple state-driven scanner.
assgn1.io Sample input and output.
Second assignment - First and Follow sets.
assignment2.htm Assignment description
Notes.html Implementation notes about the second program.
grammar_classes_2.h C++ class definitions.
grammar_impl_2.C C++ implementation of classes in grammar_classes_2.h
assgn2.out Output of program running on each test grammar.
Third assignment - LL(1) table generator.
assignment3.htm Assignment description
Notes.html Implementation notes about the third program.
grammar_classes_3.h C++ class definitions - incremental additions to the second assignment.
grammar_impl_3.C C++ implementation of classes in grammar_classes_3.h
assgn3.out Output of program running on each test grammar.
Fourth assignment - Characteristic Finite State Machine (CFSM) generator.
assignment4.htm Assignment description
Notes.html Implementation notes about the fourth program.
grammar_classes_4.h C++ class definitions - incremental additions to the third assignment.
grammar_impl_4.C C++ implementation of classes in grammar_classes_4.h
assgn4.out Output of program running on each test grammar.
grammar1.xml.html HTML version of CFSM for grammar 1.
grammar2.xml.html HTML version of CFSM for grammar 2.
grammar3.xml.html HTML version of CFSM for grammar 3.
g3.xml.html HTML version of CFSM for Fischer/Leblanc grammar G3.
micro.xml.html HTML version of CFSM for Micro grammar.
Fifth assignment - LR Parser.
assignment5.htm Assignment description
Notes.html Implementation notes about the fifth program.
grammar_classes_5.h C++ class definitions - incremental additions to the fourth assignment.
grammar_impl_5.C C++ implementation of classes in grammar_classes_5.h
assgn5.out Output of program running on two test grammars, with test parses.
Some post-assignment twiddling
gram_class.h C++ class definitions - incremental additions to the fifth assignment.
gram_impl.C C++ implementation of classes in gram_class.h
gram.out Output of program parsing using on grammar3.xml.



Presentation

Go here for details on my class presentation.



Mail me at: bwall@cs.montana.edu

Last modified: Dec. 18, 2003