summaryrefslogtreecommitdiff
path: root/old-examples/unix
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-06-25 16:54:35 +0000
committeraarne <aarne@cs.chalmers.se>2008-06-25 16:54:35 +0000
commite9e80fc389365e24d4300d7d5390c7d833a96c50 (patch)
treef0b58473adaa670bd8fc52ada419d8cad470ee03 /old-examples/unix
parentb96b36f43de3e2f8b58d5f539daa6f6d47f25870 (diff)
changed names of resource-1.3; added a note on homepage on release
Diffstat (limited to 'old-examples/unix')
-rw-r--r--old-examples/unix/Char.gf51
-rw-r--r--old-examples/unix/CharEng.gf52
-rw-r--r--old-examples/unix/CharEngLett.gf52
-rw-r--r--old-examples/unix/CharUni.gf67
-rw-r--r--old-examples/unix/Unix.gf43
-rw-r--r--old-examples/unix/UnixEng.gf43
-rw-r--r--old-examples/unix/UnixUni.gf43
7 files changed, 351 insertions, 0 deletions
diff --git a/old-examples/unix/Char.gf b/old-examples/unix/Char.gf
new file mode 100644
index 000000000..f10284587
--- /dev/null
+++ b/old-examples/unix/Char.gf
@@ -0,0 +1,51 @@
+abstract Char = {
+
+ cat
+ [Chr] {1} ; Chr ; Letter ;
+
+ fun
+ C_dot : Chr ;
+ C_pipe : Chr ;
+ C_hyphen : Chr ;
+ CSmall : Letter -> Chr ;
+ CCap : Letter -> Chr ;
+ CC : Letter -> Chr ;
+
+ CDig_0 : Chr ;
+ CDig_1 : Chr ;
+ CDig_2 : Chr ;
+ CDig_3 : Chr ;
+ CDig_4 : Chr ;
+ CDig_5 : Chr ;
+ CDig_6 : Chr ;
+ CDig_7 : Chr ;
+ CDig_8 : Chr ;
+ CDig_9 : Chr ;
+
+ L_a : Letter ;
+ L_b : Letter ;
+ L_c : Letter ;
+ L_d : Letter ;
+ L_e : Letter ;
+ L_f : Letter ;
+ L_g : Letter ;
+ L_h : Letter ;
+ L_i : Letter ;
+ L_j : Letter ;
+ L_k : Letter ;
+ L_l : Letter ;
+ L_m : Letter ;
+ L_n : Letter ;
+ L_o : Letter ;
+ L_p : Letter ;
+ L_q : Letter ;
+ L_r : Letter ;
+ L_s : Letter ;
+ L_t : Letter ;
+ L_u : Letter ;
+ L_v : Letter ;
+ L_w : Letter ;
+ L_x : Letter ;
+ L_y : Letter ;
+ L_z : Letter ;
+}
diff --git a/old-examples/unix/CharEng.gf b/old-examples/unix/CharEng.gf
new file mode 100644
index 000000000..7348278f5
--- /dev/null
+++ b/old-examples/unix/CharEng.gf
@@ -0,0 +1,52 @@
+concrete CharEng of Char = open Prelude in {
+
+lin
+ BaseChr c = c ;
+ ConsChr = infixSS "," ;
+
+ C_dot = ss "dot" ;
+ C_pipe = ss "pipe" ;
+ C_hyphen = ss (variants {"dash" ; "hyphen" ; "minus"}) ;
+ CSmall = prefixSS "small" ;
+ CCap = prefixSS "capital" ;
+ CC c = c ;
+
+ CDig_0 = ss "zero" ;
+ CDig_1 = ss "one" ;
+ CDig_2 = ss "two" ;
+ CDig_3 = ss "three" ;
+ CDig_4 = ss "four" ;
+ CDig_5 = ss "five" ;
+ CDig_6 = ss "six" ;
+ CDig_7 = ss "seven" ;
+ CDig_8 = ss "eight" ;
+ CDig_9 = ss "nine" ;
+
+ L_a = ss "alpha" ;
+ L_b = ss "bravo" ;
+ L_c = ss "charlie" ;
+ L_d = ss "delta" ;
+ L_e = ss "echo" ;
+ L_f = ss "foxtrot" ;
+ L_g = ss "golf" ;
+ L_h = ss "hotel" ;
+ L_i = ss "india" ;
+ L_j = ss "juliet" ;
+ L_k = ss "kilo" ;
+ L_l = ss "lima" ;
+ L_m = ss "mike" ;
+ L_n = ss "november" ;
+ L_o = ss "oscar" ;
+ L_p = ss "papa" ;
+ L_q = ss "quebec" ;
+ L_r = ss "romeo" ;
+ L_s = ss "sierra" ;
+ L_t = ss "tango" ;
+ L_u = ss "uniform" ;
+ L_v = ss "victor" ;
+ L_w = ss "whiskey" ;
+ L_x = ss "x-ray" ;
+ L_y = ss "yankee" ;
+ L_z = ss "zulu" ;
+
+} \ No newline at end of file
diff --git a/old-examples/unix/CharEngLett.gf b/old-examples/unix/CharEngLett.gf
new file mode 100644
index 000000000..39d9b9d16
--- /dev/null
+++ b/old-examples/unix/CharEngLett.gf
@@ -0,0 +1,52 @@
+concrete CharEng of Char = open Prelude in {
+
+lin
+ BaseChr c = c ;
+ ConsChr = infixSS "," ;
+
+ C_dot = ss "dot" ;
+ C_pipe = ss "pipe" ;
+ C_hyphen = ss (variants {"dash" ; "hyphen" ; "minus"}) ;
+ CSmall = prefixSS "small" ;
+ CCap = prefixSS "capital" ;
+ CC c = c ;
+
+ CDig_0 = ss "0" ;
+ CDig_1 = ss "1" ;
+ CDig_2 = ss "2" ;
+ CDig_3 = ss "3" ;
+ CDig_4 = ss "4" ;
+ CDig_5 = ss "5" ;
+ CDig_6 = ss "6" ;
+ CDig_7 = ss "7" ;
+ CDig_8 = ss "8" ;
+ CDig_9 = ss "9" ;
+
+ L_a = ss "A" ;
+ L_b = ss "B" ;
+ L_c = ss "C" ;
+ L_d = ss "D" ;
+ L_e = ss "E" ;
+ L_f = ss "F" ;
+ L_g = ss "G" ;
+ L_h = ss "H" ;
+ L_i = ss "I" ;
+ L_j = ss "J" ;
+ L_k = ss "K" ;
+ L_l = ss "L" ;
+ L_m = ss "M" ;
+ L_n = ss "N" ;
+ L_o = ss "O" ;
+ L_p = ss "P" ;
+ L_q = ss "Q" ;
+ L_r = ss "R" ;
+ L_s = ss "S" ;
+ L_t = ss "T" ;
+ L_u = ss "U" ;
+ L_v = ss "V" ;
+ L_w = ss "W" ;
+ L_x = ss "X" ;
+ L_y = ss "Y" ;
+ L_z = ss "Z" ;
+
+} \ No newline at end of file
diff --git a/old-examples/unix/CharUni.gf b/old-examples/unix/CharUni.gf
new file mode 100644
index 000000000..0e6628657
--- /dev/null
+++ b/old-examples/unix/CharUni.gf
@@ -0,0 +1,67 @@
+concrete CharUni of Char = open Prelude in {
+
+param
+ LForm = LCap | LSma ;
+
+oper
+ chr : Str -> Str -> {s : LForm => Str} = \c,C -> {
+ s = table {
+ LCap => C ;
+ LSma => c
+ }
+ } ;
+
+lincat
+ Letter = {s : LForm => Str} ;
+
+lin
+ BaseChr c = c ;
+ ConsChr = infixSS "&+" ;
+
+ C_dot = ss "." ;
+ C_pipe = ss "|" ;
+ C_hyphen = ss "-" ;
+ CSmall c = ss (c.s ! LSma) ;
+ CCap c = ss (c.s ! LCap) ;
+ CC c = ss (c.s ! LSma) ;
+
+ CDig_0 = ss "0" ;
+ CDig_1 = ss "1" ;
+ CDig_2 = ss "2" ;
+ CDig_3 = ss "3" ;
+ CDig_4 = ss "4" ;
+ CDig_5 = ss "5" ;
+ CDig_6 = ss "6" ;
+ CDig_7 = ss "7" ;
+ CDig_8 = ss "8" ;
+ CDig_9 = ss "9" ;
+
+
+ L_a = chr "a" "A" ;
+ L_b = chr "b" "B" ;
+ L_c = chr "c" "C" ;
+ L_d = chr "d" "D" ;
+ L_e = chr "e" "E" ;
+ L_f = chr "f" "F" ;
+ L_g = chr "g" "G" ;
+ L_h = chr "h" "H" ;
+ L_i = chr "i" "I" ;
+ L_j = chr "j" "J" ;
+ L_k = chr "k" "K" ;
+ L_l = chr "l" "L" ;
+ L_m = chr "m" "M" ;
+ L_n = chr "n" "N" ;
+ L_o = chr "o" "O" ;
+ L_p = chr "p" "P" ;
+ L_q = chr "q" "Q" ;
+ L_r = chr "r" "R" ;
+ L_s = chr "s" "S" ;
+ L_t = chr "t" "T" ;
+ L_u = chr "u" "U" ;
+ L_v = chr "v" "V" ;
+ L_w = chr "w" "W" ;
+ L_x = chr "x" "X" ;
+ L_y = chr "y" "Y" ;
+ L_z = chr "z" "Z" ;
+
+}
diff --git a/old-examples/unix/Unix.gf b/old-examples/unix/Unix.gf
new file mode 100644
index 000000000..ea5e2c2af
--- /dev/null
+++ b/old-examples/unix/Unix.gf
@@ -0,0 +1,43 @@
+abstract Unix = Char ** {
+
+ cat
+ S ; -- whole command line
+ Command ; -- one command
+ File ; -- file name
+ Word ; -- string e.g. in grep
+ [Word] {1} ; --
+
+ fun
+
+-- Catch-all: command dictated letter by letter.
+
+ CommWords : [Word] -> Command ;
+
+-- General command-line structure.
+
+ Redirect : S -> File -> S ; -- cs >f
+ Pipe : S -> Command -> S ; -- cs | c
+ Comm : Command -> S ; -- c
+
+--- This would be cool, but is it supported by speech recognition?
+--- CommOpt : (c : Command) -> [Option c] -> S ; -- c -o -k
+
+ WhatTime : Command ;
+ WhatDate : Command ;
+ WhereNow : Command ;
+ Remove : File -> Command ;
+ Copy : File -> File -> Command ;
+ Linecount : File -> Command ;
+ Wordcount : File -> Command ;
+ Grep : Word -> File -> Command ;
+ Cat : File -> Command ;
+
+ It : File ; -- no file name - contents received from pipe
+
+ FileChars : [Chr] -> File ;
+ WordChars : [Chr] -> Word ;
+
+ FileSuffix : Word -> File ; -- *suff
+ FilePrefix : Word -> File ; -- pref*
+
+}
diff --git a/old-examples/unix/UnixEng.gf b/old-examples/unix/UnixEng.gf
new file mode 100644
index 000000000..5b0ca944f
--- /dev/null
+++ b/old-examples/unix/UnixEng.gf
@@ -0,0 +1,43 @@
+--# -path=.:prelude
+
+concrete UnixEng of Unix = CharEng ** open Prelude in {
+
+ flags lexer=text ;
+
+{-
+ lincat
+ Line ;
+ [Command] {1} ;
+ Command ;
+ File ;
+-}
+
+ lin
+ CommWords w = w ;
+
+ Redirect = infixSS (optStr "and" ++ ["write the result to"]) ;
+ Pipe = infixSS "then" ;
+ Comm c = c ;
+
+ WhatTime = ss ["what time is it"] ;
+ WhatDate = ss ["what date is it"] ;
+ WhereNow = ss ["where am I now"] ;
+ Remove = prefixSS "remove" ;
+ Copy x y = ss ("copy" ++ x.s ++ "to" ++ y.s) ;
+ Linecount = prefixSS ["how many lines has"] ;
+ Wordcount = prefixSS ["how many words has"] ;
+ Grep x y = ss (["show the lines containing"] ++ x.s ++ "in" ++ y.s) ;
+ Cat = prefixSS ["show the contents of"] ;
+
+ It = ss "it" ;
+
+ FileChars = prefixSS (optStr ["the file"]) ;
+ WordChars = prefixSS (optStr ["the word"]) ;
+
+ FileSuffix = prefixSS ["all files ending with"] ;
+ FilePrefix = prefixSS ["all files beginning with"] ;
+
+ BaseWord w = w ;
+ ConsWord = infixSS "space" ;
+
+}
diff --git a/old-examples/unix/UnixUni.gf b/old-examples/unix/UnixUni.gf
new file mode 100644
index 000000000..b1b220824
--- /dev/null
+++ b/old-examples/unix/UnixUni.gf
@@ -0,0 +1,43 @@
+--# -path=.:prelude
+
+concrete UnixUni of Unix = CharUni ** open Prelude in {
+
+ flags unlexer=bind ;
+
+{-
+ lincat
+ Line ;
+ [Command] {1} ;
+ Command ;
+ File ;
+-}
+
+ lin
+ CommWords w = w ;
+
+ Redirect = infixSS ">" ;
+ Pipe = infixSS "|" ;
+ Comm c = c ;
+
+ WhatTime = ss ["date +%D"] ;
+ WhatDate = ss ["date +%T"] ;
+ WhereNow = ss ["pwd"] ;
+ Remove = prefixSS "rm" ;
+ Copy x y = ss ("cp" ++ x.s ++ y.s) ;
+ Linecount = prefixSS ["wc -l"] ;
+ Wordcount = prefixSS ["wc -w"] ;
+ Grep x y = ss ("grep" ++ x.s ++ y.s) ;
+ Cat = prefixSS "cat" ;
+
+ It = ss [] ;
+
+ FileChars c = c ;
+ WordChars c = c ;
+
+ FileSuffix = prefixSS ["* &+"] ;
+ FilePrefix = postfixSS ["&+ *"] ;
+
+ BaseWord w = w ;
+ ConsWord = cc2 ;
+
+}