summaryrefslogtreecommitdiff
path: root/grammars/prelude
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-08-14 07:58:04 +0000
committerbjorn <bjorn@bringert.net>2008-08-14 07:58:04 +0000
commit77270a010a0b453e9a84c3e62db7cfd22e49d55d (patch)
treed17682a545d6ac1e68ff49b8c20964182794baf7 /grammars/prelude
parent0bbb906141711767678f82b15a7b43e65e0b5bd6 (diff)
Remove the grammars directory. It was full of old grammars that don't compile these days. See the old source distributions if you want them.
Diffstat (limited to 'grammars/prelude')
-rw-r--r--grammars/prelude/Coordination.gf105
-rw-r--r--grammars/prelude/HTML.gf8
-rw-r--r--grammars/prelude/Latex.gf12
-rw-r--r--grammars/prelude/Precedence.gf117
-rw-r--r--grammars/prelude/Predef.gf27
-rw-r--r--grammars/prelude/PredefAbs.gf4
-rw-r--r--grammars/prelude/Prelude.gf100
-rw-r--r--grammars/prelude/README20
8 files changed, 0 insertions, 393 deletions
diff --git a/grammars/prelude/Coordination.gf b/grammars/prelude/Coordination.gf
deleted file mode 100644
index 6ed4af791..000000000
--- a/grammars/prelude/Coordination.gf
+++ /dev/null
@@ -1,105 +0,0 @@
-resource Coordination = {
-
-param
- ListSize = TwoElem | ManyElem ;
-
-oper
- SS = {s : Str} ; ----
-
- ListX = {s1,s2 : Str} ;
-
- twoStr : (x,y : Str) -> ListX = \x,y ->
- {s1 = x ; s2 = y} ;
- consStr : Str -> ListX -> Str -> ListX = \comma,xs,x ->
- {s1 = xs.s1 ++ comma ++ xs.s2 ; s2 = x } ;
-
- twoSS : (_,_ : SS) -> ListX = \x,y ->
- twoStr x.s y.s ;
- consSS : Str -> ListX -> SS -> ListX = \comma,xs,x ->
- consStr comma xs x.s ;
-
- Conjunction : Type = SS ;
- ConjunctionDistr : Type = {s1 : Str ; s2 : Str} ;
-
- conjunctX : Conjunction -> ListX -> Str = \or,xs ->
- xs.s1 ++ or.s ++ xs.s2 ;
-
- conjunctDistrX : ConjunctionDistr -> ListX -> Str = \or,xs ->
- or.s1 ++ xs.s1 ++ or.s2 ++ xs.s2 ;
-
- -- all this lifted to tables
-
- ListTable : Type -> Type = \P -> {s1,s2 : P => Str} ;
-
- twoTable : (P : Type) -> (_,_ : {s : P => Str}) -> ListTable P = \_,x,y ->
- {s1 = x.s ; s2 = y.s} ;
-
- consTable : (P : Type) -> Str -> ListTable P -> {s : P => Str} -> ListTable P =
- \P,c,xs,x ->
- {s1 = table P {o => xs.s1 ! o ++ c ++ xs.s2 ! o} ; s2 = x.s} ;
-
- conjunctTable : (P : Type) -> Conjunction -> ListTable P -> {s : P => Str} =
- \P,or,xs ->
- {s = table P {p => xs.s1 ! p ++ or.s ++ xs.s2 ! p}} ;
-
- conjunctDistrTable :
- (P : Type) -> ConjunctionDistr -> ListTable P -> {s : P => Str} = \P,or,xs ->
- {s = table P {p => or.s1++ xs.s1 ! p ++ or.s2 ++ xs.s2 ! p}} ;
-
- -- ... and to two- and three-argument tables: how clumsy! ---
-
- ListTable2 : Type -> Type -> Type = \P,Q ->
- {s1,s2 : P => Q => Str} ;
-
- twoTable2 : (P,Q : Type) -> (_,_ : {s : P => Q => Str}) -> ListTable2 P Q =
- \_,_,x,y ->
- {s1 = x.s ; s2 = y.s} ;
-
- consTable2 :
- (P,Q : Type) -> Str -> ListTable2 P Q -> {s : P => Q => Str} -> ListTable2 P Q =
- \P,Q,c,xs,x ->
- {s1 = table P {p => table Q {q => xs.s1 ! p ! q ++ c ++ xs.s2 ! p! q}} ;
- s2 = x.s
- } ;
-
- conjunctTable2 :
- (P,Q : Type) -> Conjunction -> ListTable2 P Q -> {s : P => Q => Str} =
- \P,Q,or,xs ->
- {s = table P {p => table Q {q => xs.s1 ! p ! q ++ or.s ++ xs.s2 ! p ! q}}} ;
-
- conjunctDistrTable2 :
- (P,Q : Type) -> ConjunctionDistr -> ListTable2 P Q -> {s : P => Q => Str} =
- \P,Q,or,xs ->
- {s =
- table P {p => table Q {q => or.s1++ xs.s1 ! p ! q ++ or.s2 ++ xs.s2 ! p ! q}}} ;
-
- ListTable3 : Type -> Type -> Type -> Type = \P,Q,R ->
- {s1,s2 : P => Q => R => Str} ;
-
- twoTable3 : (P,Q,R : Type) -> (_,_ : {s : P => Q => R => Str}) ->
- ListTable3 P Q R =
- \_,_,_,x,y ->
- {s1 = x.s ; s2 = y.s} ;
-
- consTable3 :
- (P,Q,R : Type) -> Str -> ListTable3 P Q R -> {s : P => Q => R => Str} ->
- ListTable3 P Q R =
- \P,Q,R,c,xs,x ->
- {s1 = \\p,q,r => xs.s1 ! p ! q ! r ++ c ++ xs.s2 ! p ! q ! r ;
- s2 = x.s
- } ;
-
- conjunctTable3 :
- (P,Q,R : Type) -> Conjunction -> ListTable3 P Q R -> {s : P => Q => R => Str} =
- \P,Q,R,or,xs ->
- {s = \\p,q,r => xs.s1 ! p ! q ! r ++ or.s ++ xs.s2 ! p ! q ! r} ;
-
- conjunctDistrTable3 :
- (P,Q,R : Type) -> ConjunctionDistr -> ListTable3 P Q R ->
- {s : P => Q => R => Str} =
- \P,Q,R,or,xs ->
- {s = \\p,q,r => or.s1++ xs.s1 ! p ! q ! r ++ or.s2 ++ xs.s2 ! p ! q ! r} ;
-
- comma = "," ;
-
-} ;
diff --git a/grammars/prelude/HTML.gf b/grammars/prelude/HTML.gf
deleted file mode 100644
index b469b582c..000000000
--- a/grammars/prelude/HTML.gf
+++ /dev/null
@@ -1,8 +0,0 @@
-resource HTML = open Prelude in {
- oper
- tag : Str -> Str = \t -> "<" + t + ">" ;
- endtag : Str -> Str = \t -> tag ("/" + t) ;
- intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ endtag t ;
- intagAttr : Str -> Str -> Str -> Str =
- \t,a,s -> ("<" + t) ++ (a + ">") ++ s ++ endtag t ;
-}
diff --git a/grammars/prelude/Latex.gf b/grammars/prelude/Latex.gf
deleted file mode 100644
index 2fd2f9ec8..000000000
--- a/grammars/prelude/Latex.gf
+++ /dev/null
@@ -1,12 +0,0 @@
-resource Latex = open Prelude in {
- oper
- command : Str -> Str = \c -> "\\" + c ;
- fun1 : Str -> Str -> Str = \f,x -> "\\" + f + "{" ++ x ++ "}" ;
- fun2 : Str -> Str -> Str -> Str =
- \f,x,y -> "\\" + f + "{" ++ x ++ "}{" ++ y ++ "}" ;
- begin : Str -> Str = \e -> "\\begin{" + e + "}" ;
- end : Str -> Str = \e -> "\\end{" + e + "}" ;
- inEnv : Str -> Str -> Str = \e,s -> begin e ++ s ++ end e ;
-}
-
-
diff --git a/grammars/prelude/Precedence.gf b/grammars/prelude/Precedence.gf
deleted file mode 100644
index 1e0b1a77c..000000000
--- a/grammars/prelude/Precedence.gf
+++ /dev/null
@@ -1,117 +0,0 @@
--- operations for precedence-dependent strings.
--- five levels:
--- p4 (constants), p3 (applications), p2 (products), p1 (sums), p0 (arrows)
-
-resource Precedence = open Prelude in {
-
-param
-Prec = p4 | p3 | p2 | p1 | p0 ;
-
-lintype
-PrecTerm = Prec => Str ;
-
-oper
-pss : PrecTerm -> {s : PrecTerm} = \s -> {s = s} ;
-
-
--- change this if you want some other type of parentheses
-mkParenth : Str -> Str = \str -> "(" ++ str ++ ")" ;
-
--- define ordering of precedences
-nextPrec : Prec => Prec =
- table {p0 => p1 ; p1 => p2 ; p2 => p3 ; _ => p4} ;
-prevPrec : Prec => Prec =
- table {p4 => p3 ; p3 => p2 ; p2 => p1 ; _ => p0} ;
-
-mkPrec : Str -> Prec => Prec => Str = \str ->
- table {
- p4 => table { -- use the term of precedence p4...
- _ => str} ; -- ...always without parentheses
- p3 => table { -- use the term of precedence p3...
- p4 => mkParenth str ; -- ...in parentheses if p4 is required...
- _ => str} ; -- ...otherwise without parentheses
- p2 => table {
- p4 => mkParenth str ;
- p3 => mkParenth str ;
- _ => str} ;
- p1 => table {
- p1 => str ;
- p0 => str ;
- _ => mkParenth str} ;
- p0 => table {
- p0 => str ;
- _ => mkParenth str}
- } ;
-
--- make a string into a constant, of precedence p4
-mkConst : Str -> PrecTerm =
- \f ->
- mkPrec f ! p4 ;
-
--- make a string into a 1/2/3 -place prefix operator, of precedence p3
-mkFun1 : Str -> PrecTerm -> PrecTerm =
- \f -> \x ->
- table {k => mkPrec (f ++ x ! p4) ! p3 ! k} ;
-mkFun2 : Str -> PrecTerm -> PrecTerm -> PrecTerm =
- \f -> \x -> \y ->
- table {k => mkPrec (f ++ x ! p4 ++ y ! p4) ! p3 ! k} ;
-mkFun3 : Str -> PrecTerm -> PrecTerm -> PrecTerm -> PrecTerm =
- \f -> \x -> \y -> \z ->
- table {k => mkPrec (f ++ x ! p4 ++ y ! p4 ++ z ! p4) ! p3 ! k} ;
-
--- make a string into a non/left/right -associative infix operator, of precedence p
-mkInfix : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
- \f -> \p -> \x -> \y ->
- table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! (nextPrec ! p)) ! p ! k} ;
-mkInfixL : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
- \f -> \p -> \x -> \y ->
- table {k => mkPrec (x ! p ++ f ++ y ! (nextPrec ! p)) ! p ! k} ;
-mkInfixR : Str -> Prec -> PrecTerm -> PrecTerm -> PrecTerm =
- \f -> \p -> \x -> \y ->
- table {k => mkPrec (x ! (nextPrec ! p) ++ f ++ y ! p) ! p ! k} ;
-
------------------------------------------------------------
-
--- alternative:
--- precedence as inherent feature
-
-lintype TermWithPrec = {s : Str ; p : Prec} ;
-
-oper
-mkpPrec : Str -> Prec -> TermWithPrec =
- \f -> \p ->
- {s = f ; p = p} ;
-
-usePrec : TermWithPrec -> Prec -> Str =
- \x -> \p ->
- mkPrec x.s ! x.p ! p ;
-
--- make a string into a constant, of precedence p4
-mkpConst : Str -> TermWithPrec =
- \f ->
- mkpPrec f p4 ;
-
--- make a string into a 1/2/3 -place prefix operator, of precedence p3
-mkpFun1 : Str -> TermWithPrec -> TermWithPrec =
- \f -> \x ->
- mkpPrec (f ++ usePrec x p4) p3 ;
-
-mkpFun2 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec =
- \f -> \x -> \y ->
- mkpPrec (f ++ usePrec x p4 ++ usePrec y p4) p3 ;
-
-mkpFun3 : Str -> TermWithPrec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
- \f -> \x -> \y -> \z ->
- mkpPrec (f ++ usePrec x p4 ++ usePrec y p4 ++ usePrec z p4) p3 ;
-
--- make a string a into non/left/right -associative infix operator, of precedence p
-mkpInfix : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
- \f -> \p -> \x -> \y ->
- mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y (nextPrec ! p)) p ;
-mkpInfixL : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
- \f -> \p -> \x -> \y ->
- mkpPrec (usePrec x p ++ f ++ usePrec y (nextPrec ! p)) p ;
-mkpInfixR : Str -> Prec -> TermWithPrec -> TermWithPrec -> TermWithPrec =
- \f -> \p -> \x -> \y ->
- mkpPrec (usePrec x (nextPrec ! p) ++ f ++ usePrec y p) p ;
-} ; \ No newline at end of file
diff --git a/grammars/prelude/Predef.gf b/grammars/prelude/Predef.gf
deleted file mode 100644
index 866ce5b6a..000000000
--- a/grammars/prelude/Predef.gf
+++ /dev/null
@@ -1,27 +0,0 @@
--- predefined functions for concrete syntax, defined in AppPredefined.hs
-
-resource Predef = {
-
- -- this type is for internal use only
- param PBool = PTrue | PFalse ;
-
- -- these operations have their proper definitions in AppPredefined.hs
-
- oper Int : Type = variants {} ; -- the type of integers
- oper Ints : Int -> Type = variants {} ; -- the type of integers from 0 to n
-
- oper length : Tok -> Int = variants {} ; -- length of string
- oper drop : Int -> Tok -> Tok = variants {} ; -- drop prefix of length
- oper take : Int -> Tok -> Tok = variants {} ; -- take prefix of length
- oper tk : Int -> Tok -> Tok = variants {} ; -- drop suffix of length
- oper dp : Int -> Tok -> Tok = variants {} ; -- take suffix of length
- oper eqInt : Int -> Int -> PBool = variants {} ; -- test if equal integers
- oper lessInt: Int -> Int -> PBool = variants {} ; -- test order of integers
- oper plus : Int -> Int -> Int = variants {} ; -- add integers
- oper eqStr : Tok -> Tok -> PBool = variants {} ; -- test if equal strings
- oper occur : Tok -> Tok -> PBool = variants {} ; -- test if occurs as substring
- oper show : (P : Type) -> P -> Tok = variants {} ; -- convert param to string
- oper read : (P : Type) -> Tok -> P = variants {} ; -- convert string to param
-
- } ;
-
diff --git a/grammars/prelude/PredefAbs.gf b/grammars/prelude/PredefAbs.gf
deleted file mode 100644
index 2779bcd58..000000000
--- a/grammars/prelude/PredefAbs.gf
+++ /dev/null
@@ -1,4 +0,0 @@
-abstract PredefAbs = {
- cat Int ; String ;
-} ;
-
diff --git a/grammars/prelude/Prelude.gf b/grammars/prelude/Prelude.gf
deleted file mode 100644
index c84fa6188..000000000
--- a/grammars/prelude/Prelude.gf
+++ /dev/null
@@ -1,100 +0,0 @@
--- language-independent prelude facilities
-
-resource Prelude = open (Predef=Predef) in {
-
-oper
--- to construct records and tables
- SS : Type = {s : Str} ;
- ss : Str -> SS = \s -> {s = s} ;
- ss2 : (_,_ : Str) -> SS = \x,y -> ss (x ++ y) ;
- ss3 : (_,_ ,_: Str) -> SS = \x,y,z -> ss (x ++ y ++ z) ;
-
- cc2 : (_,_ : SS) -> SS = \x,y -> ss (x.s ++ y.s) ;
-
- SS1 : Type -> Type = \P -> {s : P => Str} ;
- ss1 : (A : Type) -> Str -> SS1 A = \A,s -> {s = table {_ => s}} ;
-
- SP1 : Type -> Type = \P -> {s : Str ; p : P} ;
- sp1 : (A : Type) -> Str -> A -> SP1 A = \_,s,a -> {s = s ; p = a} ;
-
- nonExist : Str = variants {} ;
-
- optStr : Str -> Str = \s -> variants {s ; []} ;
-
- constTable : (A,B : Type) -> B -> A => B = \_,_,b -> \\_ => b ;
- constStr : (A : Type) -> Str -> A => Str = \A -> constTable A Str ;
-
- infixSS : Str -> SS -> SS -> SS = \f,x,y -> ss (x.s ++ f ++ y.s) ;
- prefixSS : Str -> SS -> SS = \f,x -> ss (f ++ x.s) ;
- postfixSS : Str -> SS -> SS = \f,x -> ss (x.s ++ f) ;
- embedSS : Str -> Str -> SS -> SS = \f,g,x -> ss (f ++ x.s ++ g) ;
-
- id : (A : Type) -> A -> A ;
-
--- discontinuous
- SD2 = {s1,s2 : Str} ;
- sd2 : (_,_ : Str) -> SD2 = \x,y -> {s1 = x ; s2 = y} ;
-
--- parentheses
- paren : Str -> Str = \s -> "(" ++ s ++ ")" ;
- parenss : SS -> SS = \s -> ss (paren s.s) ;
-
--- free order between two strings
- bothWays : Str -> Str -> Str = \x,y -> variants {x ++ y ; y ++ x} ;
-
--- parametric order between two strings
- preOrPost : Bool -> Str -> Str -> Str = \pr,x,y ->
- if_then_Str pr (x ++ y) (y ++ x) ;
-
--- Booleans
-
- param Bool = True | False ;
-
-oper
- if_then_else : (A : Type) -> Bool -> A -> A -> A = \_,c,d,e ->
- case c of {
- True => d ; ---- should not need to qualify
- False => e
- } ;
-
- andB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a b False ;
- orB : (_,_ : Bool) -> Bool = \a,b -> if_then_else Bool a True b ;
- notB : Bool -> Bool = \a -> if_then_else Bool a False True ;
-
- if_then_Str : Bool -> Str -> Str -> Str = if_then_else Str ;
-
--- zero, one, two, or more (elements in a list etc)
-
-param
- ENumber = E0 | E1 | E2 | Emore ;
-
-oper
- eNext : ENumber -> ENumber = \e -> case e of {
- E0 => E1 ; E1 => E2 ; _ => Emore} ;
-
- -- these were defined in Predef before
- isNil : Tok -> Bool = \b -> pbool2bool (Predef.eqStr [] b) ;
-
- ifTok : (A : Type) -> Tok -> Tok -> A -> A -> A = \A,t,u,a,b ->
- case Predef.eqStr t u of {Predef.PTrue => a ; Predef.PFalse => b} ;
-
- -- so we need an interface
- pbool2bool : Predef.PBool -> Bool = \b -> case b of {
- Predef.PFalse => False ; Predef.PTrue => True
- } ;
-
- init : Tok -> Tok = Predef.tk 1 ;
- last : Tok -> Tok = Predef.dp 1 ;
-
-
--- bind together two tokens in the lexer, either obligatorily or optionally
-
- oper
- glue : Str -> Str -> Str = \x,y -> x ++ BIND ++ y ;
- glueOpt : Str -> Str -> Str = \x,y -> variants {glue x y ; x ++ y} ;
- noglueOpt : Str -> Str -> Str = \x,y -> variants {x ++ y ; glue x y} ;
-
--- these should be hidden, and never changed since it's hardcoded in (un)lexers
- BIND : Str = "&+" ;
- PARA : Str = "&-" ;
-} ;
diff --git a/grammars/prelude/README b/grammars/prelude/README
deleted file mode 100644
index c499de763..000000000
--- a/grammars/prelude/README
+++ /dev/null
@@ -1,20 +0,0 @@
-Generic (i.e. language-independent) resources.
-
- Coordination -- building lists; used in resource/*/
- HTML -- printing with HTML formatting
- Latex -- printing with Latex formatting
- Precedence -- precedence levels and the use of parentheses
- Predef -- type signatures of predefined opers
- PredefAbs -- type signatures of predefined cats
- Prelude -- useful string operations
-
-Predef and PredefAbs no longer have to be imported explicitly
-in GF 2.0.
-
-Copyright (c) 2004 Aarne Ranta
-under GNU General Public License (GPL).
-
-Document last updated August 3, 2004.
-
-
-