summaryrefslogtreecommitdiff
path: root/examples/godis-tram/Common/Prolog.gf
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2006-11-08 15:08:09 +0000
committeraarne <aarne@cs.chalmers.se>2006-11-08 15:08:09 +0000
commiteb3d750459c5ab6fd0fa2266175e1ad4a4e3d33f (patch)
tree8171f7d4ed14c9821a508a6471ee8733fdc7808f /examples/godis-tram/Common/Prolog.gf
parent1fd01130157b81d1b8f4e334f93efa25acf0ecc3 (diff)
godis tram grammars, augmented with Fin
Diffstat (limited to 'examples/godis-tram/Common/Prolog.gf')
-rw-r--r--examples/godis-tram/Common/Prolog.gf60
1 files changed, 60 insertions, 0 deletions
diff --git a/examples/godis-tram/Common/Prolog.gf b/examples/godis-tram/Common/Prolog.gf
new file mode 100644
index 000000000..461ed470e
--- /dev/null
+++ b/examples/godis-tram/Common/Prolog.gf
@@ -0,0 +1,60 @@
+resource Prolog = {
+
+oper
+
+PStr : Type = {s : Str};
+PPStr : Type = PStr -> PStr;
+PPPStr : Type = PStr -> PStr -> PStr;
+PPPPStr : Type = PStr -> PStr -> PStr -> PStr;
+PPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr;
+PPPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr -> PStr;
+PPPPPPPStr : Type = PStr -> PStr -> PStr -> PStr -> PStr -> PStr -> PStr;
+
+pStr : Str -> PStr = \str -> {s = str};
+pOper : Str -> PPPStr = \f,x,y -> pStr (x.s ++ f ++ y.s);
+pPrefix : Str -> PPStr = \f,x -> pStr (f ++ x.s);
+pPostfix : Str -> PPStr = \f,x -> pStr (x.s ++ f);
+pEmbed : Str -> Str -> PPStr = \f,g,x -> pStr (f ++ x.s ++ g);
+pParen : PPStr = pEmbed "(" ")";
+pBrackets: PPStr = pEmbed "[" "]";
+
+pAtom : PPStr = \x -> pStr ("'" + x.s + "'");
+pQuote : PPStr = pEmbed "'" "'";
+pDQuote : PPStr = pEmbed "\"" "\"";
+
+pNil : PStr = pStr "''";
+pEmpty : PStr = pStr [];
+
+pp0 : Str -> PStr = pStr;
+pp1 : Str -> PPStr = \pred,arg -> pPrefix pred (pParen arg);
+pp2 : Str -> PPPStr = \pred,arg1,arg2 -> pp1 pred (pSeq arg1 arg2);
+pp3 : Str -> PPPPStr = \pred,arg1,arg2 -> pp2 pred (pSeq arg1 arg2);
+pp4 : Str -> PPPPPStr = \pred,arg1,arg2 -> pp3 pred (pSeq arg1 arg2);
+pp5 : Str -> PPPPPPStr = \pred,arg1,arg2 -> pp4 pred (pSeq arg1 arg2);
+pp6 : Str -> PPPPPPPStr = \pred,arg1,arg2 -> pp5 pred (pSeq arg1 arg2);
+
+pList0 : PStr = pBrackets pEmpty;
+pList1 : PPStr = \x -> pBrackets x;
+pList2 : PPPStr = \x,y -> pList1 (pSeq x y);
+pList3 : PPPPStr = \x,y -> pList2 (pSeq x y);
+pList4 : PPPPPStr = \x,y -> pList3 (pSeq x y);
+pList5 : PPPPPPStr = \x,y -> pList4 (pSeq x y);
+pList6 : PPPPPPPStr = \x,y -> pList5 (pSeq x y);
+
+pSeq : PPPStr = pOper ",";
+
+pConcat : PPPStr = \x,y -> pStr (x.s ++ y.s);
+
+-- the following operations are Godis-specific
+
+pWhQ : Str -> PStr = \pred -> pOper "^" pVar (pp1 pred pVar);
+pVar : PStr = pStr "X";
+
+pm1 : PPStr = \x -> x;
+pm2 : PPPStr = \x,y -> pm1 (pSeq x y);
+pm3 : PPPPStr = \x,y -> pm2 (pSeq x y);
+pm4 : PPPPPStr = \x,y -> pm3 (pSeq x y);
+pm5 : PPPPPPStr = \x,y -> pm4 (pSeq x y);
+pm6 : PPPPPPPStr = \x,y -> pm5 (pSeq x y);
+
+}