Skip to content

Commit 0db8b2f

Browse files
committed
Build w/ cabal, README, LICENSE, and more structure
1 parent 52fd3fe commit 0db8b2f

File tree

6 files changed

+741
-0
lines changed

6 files changed

+741
-0
lines changed

LICENSE

+674
Large diffs are not rendered by default.

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Principles of Program Analysis in Haskell
2+
## by Flemming Nielson, Hanne Riis Nielson, and Chris Hankin
3+
4+
### Summary
5+
6+
Implementations of analyses from Principles of Program Analysis by Nielson, Nielson, and Hankin.
7+
The implementations are all written in Haskell, and example analyses are all parsed directly from the
8+
book.
9+
10+
### Building
11+
12+
% git clone [email protected]:Isweet/ppa.git
13+
% cd ppa
14+
% cabal sandbox init
15+
% cabal build --ghc
16+
% cabal test
17+
18+
### Parser
19+
20+
The parser for the While language (section 1.2, page 3) is written in Parsec. It is almost exactly
21+
the parser presented in [https://wiki.haskell.org/Parsing\_a\_simple\_imperative\_language](https://wiki.haskell.org/Parsing_a_simple_imperative_language),
22+
except that it includes functionality for generating a labeled AST.
23+
24+
Make sure you have a sandbox created (as per the build instructions above), then:
25+
26+
% cabal repl
27+
*PPA.While> let factorial = "y:=x; z:=1; while y>1 do (z:=z*y; y:=y-1); y:=0"
28+
*PPA.While> let s = parse factorial
29+
*PPA.While> showL s
30+
"[y := x]^1; [z := 1]^2; while [(y > 1)]^3 do ([z := (z * y)]^4; [y := (y - 1)]^5); [y := 0]^6"
31+
*PPA.While> wflow s
32+
fromList [(1,2),(2,3),(3,4),(3,6),(4,5),(5,3)]

Setup.hs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Distribution.Simple
2+
main = defaultMain

ppa.cabal

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- Initial ppa.cabal generated by cabal init. For further documentation,
2+
-- see http://haskell.org/cabal/users-guide/
3+
4+
name: ppa
5+
version: 0.1.0.0
6+
synopsis: Principles of Program Analysis in Haskell
7+
-- description:
8+
homepage: https://github.com/Isweet/ppa
9+
license: GPL-3
10+
license-file: LICENSE
11+
author: Ian Sweet
12+
maintainer: [email protected]
13+
-- copyright:
14+
category: Static Analysis
15+
build-type: Simple
16+
extra-source-files: README.md
17+
cabal-version: >=1.10
18+
19+
library
20+
exposed-modules: PPA.While
21+
-- other-modules:
22+
other-extensions: FlexibleContexts
23+
build-depends: base >=4.8 && <4.9, mtl >=2.2 && <2.3, parsec >=3.1 && <3.2, containers >=0.5 && <0.6
24+
hs-source-dirs: src
25+
default-language: Haskell2010
26+
27+
Test-Suite tests
28+
type: exitcode-stdio-1.0
29+
main-is: Main.hs
30+
hs-source-dirs: test
31+
build-depends: base, containers >=0.5 && <0.6, ppa

PPA/While.hs src/PPA/While.hs

File renamed without changes.

test/Main.hs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
module Main (main) where
2+
13
import PPA.While
24

35
import qualified Data.Set as Set

0 commit comments

Comments
 (0)