Memphis
Examples
Manuals
Distribution
|
-
Domain Declarations and Match Statements
discusses how to write domain declarations like
domain Tree {
node(int val, Tree left, Tree right)
empty()
}
that describe data types in a grammatical style,
and match statements such as
match t {
rule node(v, l, r) :
return v + Sum(l) + Sum(r);
rule empty() :
return 0;
}
that process the data by inductively following their structure.
-
Writing an Interpreter with Lex, Yacc, and Memphis
shows how to specify an interpreter for a little language
in which one can write programs like this:
// Greatest Common Divisor
x := 8;
y := 12;
WHILE x != y DO
IF x > y THEN x := x-y
ELSE y := y-x
FI
OD;
PRINT x
|