CS 3040 Sample Programs and Problems

Python

Haskell

  • myDrop.hs: a recursive re-implementation of Haskell's drop function. patternDrop.hs computes the same result but using patterns in the argument lists. These are discussed in the week 3 notes.
  • A Haskell implementation of a finite state machine

  • card.hs: a short example illustrating defining a data type and writing a function processing that type.
  • Top-down, bottom-up parsers
  • nats.hs: Natural numbers
  • C++

  • simple-expr-recognizer.cpp: a recursive-descent parser implementing an expression recognizer. This serves as an introduction to recursive descent parsing.
  • simple-expr.cpp: expression parser with evaluation.
  • expr.cpp: recursive-descent parser for expressions over +, -, *, /, (, and )

    ANTLR

    All ANTLR examples