mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
extended unix grammars with character-based spelling
This commit is contained in:
@@ -1857,7 +1857,7 @@ they can be used as arguments. For example:
|
|||||||
|
|
||||||
-- e.g. (StreetAddress 10 "Downing Street") : Address
|
-- e.g. (StreetAddress 10 "Downing Street") : Address
|
||||||
```
|
```
|
||||||
|
The linearization type is ``{s : Str}`` for all these categories.
|
||||||
|
|
||||||
|
|
||||||
==More concepts of abstract syntax==
|
==More concepts of abstract syntax==
|
||||||
@@ -1922,16 +1922,30 @@ documents:
|
|||||||
However, to give a flavour of both using and writing resource grammars,
|
However, to give a flavour of both using and writing resource grammars,
|
||||||
we have created a miniature resource, which resides in the
|
we have created a miniature resource, which resides in the
|
||||||
subdirectory [``resource`` resource]. Its API consists of the following
|
subdirectory [``resource`` resource]. Its API consists of the following
|
||||||
modules:
|
three modules:
|
||||||
- [Syntax resource/Syntax.gf]: syntactic structures, language-independent
|
|
||||||
- [LexEng resource/LexEng.gf]: lexical paradigms, English
|
[Syntax resource/Syntax.gf] - syntactic structures, language-independent:
|
||||||
- [LexIta resource/LexIta.gf]: lexical paradigms, Italian
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
[LexEng resource/LexEng.gf] - lexical paradigms, English:
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
[LexIta resource/LexIta.gf] - lexical paradigms, Italian:
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Only these three modules should be ``open``ed in applications.
|
Only these three modules should be ``open``ed in applications.
|
||||||
The implementations of the resource are given in the following four modules:
|
The implementations of the resource are given in the following four modules:
|
||||||
- [MorphoEng resource/MorphoEng.gf],
|
|
||||||
[MorphoIta resource/MorphoIta.gf]: low-level morphology
|
[MorphoEng resource/MorphoEng.gf],
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
[MorphoIta resource/MorphoIta.gf]: low-level morphology
|
||||||
- [SyntaxEng resource/SyntaxEng.gf].
|
- [SyntaxEng resource/SyntaxEng.gf].
|
||||||
[SyntaxIta resource/SyntaxIta.gf]: definitions of syntactic structures
|
[SyntaxIta resource/SyntaxIta.gf]: definitions of syntactic structures
|
||||||
|
|
||||||
|
|||||||
51
examples/unix/Char.gf
Normal file
51
examples/unix/Char.gf
Normal file
@@ -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 ;
|
||||||
|
}
|
||||||
52
examples/unix/CharEng.gf
Normal file
52
examples/unix/CharEng.gf
Normal file
@@ -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" ;
|
||||||
|
|
||||||
|
}
|
||||||
67
examples/unix/CharUni.gf
Normal file
67
examples/unix/CharUni.gf
Normal file
@@ -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" ;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,24 +1,43 @@
|
|||||||
abstract Unix = {
|
abstract Unix = Char ** {
|
||||||
|
|
||||||
cat
|
cat
|
||||||
S ;
|
S ; -- whole command line
|
||||||
Line ;
|
Command ; -- one command
|
||||||
Command ;
|
File ; -- file name
|
||||||
File ;
|
Word ; -- string e.g. in grep
|
||||||
|
[Word] {1} ; --
|
||||||
|
|
||||||
fun
|
fun
|
||||||
Pipe : Command -> S -> S ;
|
|
||||||
Comm : Command -> S ;
|
-- 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 ;
|
WhatTime : Command ;
|
||||||
WhatDate : Command ;
|
WhatDate : Command ;
|
||||||
WhereNow : Command ;
|
WhereNow : Command ;
|
||||||
Remove : File -> Command ;
|
Remove : File -> Command ;
|
||||||
Copy : File -> File -> Command ;
|
Copy : File -> File -> Command ;
|
||||||
Linecount : File -> Command ;
|
Linecount : File -> Command ;
|
||||||
Wordcount : File -> Command ;
|
Wordcount : File -> Command ;
|
||||||
|
Grep : Word -> File -> Command ;
|
||||||
|
Cat : File -> Command ;
|
||||||
|
|
||||||
Name : String -> File ;
|
It : File ; -- no file name - contents received from pipe
|
||||||
It : File ;
|
|
||||||
|
FileChars : [Chr] -> File ;
|
||||||
|
WordChars : [Chr] -> Word ;
|
||||||
|
|
||||||
|
FileSuffix : Word -> File ; -- *suff
|
||||||
|
FilePrefix : Word -> File ; -- pref*
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
--# -path=.:prelude
|
--# -path=.:prelude
|
||||||
|
|
||||||
concrete UnixEng of Unix = open Prelude in {
|
concrete UnixEng of Unix = CharEng ** open Prelude in {
|
||||||
|
|
||||||
flags unlexer=textlit ; lexer=textlit ;
|
flags lexer=text ;
|
||||||
|
|
||||||
{-
|
{-
|
||||||
lincat
|
lincat
|
||||||
@@ -13,6 +13,9 @@ concrete UnixEng of Unix = open Prelude in {
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
lin
|
lin
|
||||||
|
CommWords w = w ;
|
||||||
|
|
||||||
|
Redirect = infixSS (optStr "and" ++ ["write the result to"]) ;
|
||||||
Pipe = infixSS "then" ;
|
Pipe = infixSS "then" ;
|
||||||
Comm c = c ;
|
Comm c = c ;
|
||||||
|
|
||||||
@@ -23,8 +26,18 @@ concrete UnixEng of Unix = open Prelude in {
|
|||||||
Copy x y = ss ("copy" ++ x.s ++ "to" ++ y.s) ;
|
Copy x y = ss ("copy" ++ x.s ++ "to" ++ y.s) ;
|
||||||
Linecount = prefixSS ["how many lines has"] ;
|
Linecount = prefixSS ["how many lines has"] ;
|
||||||
Wordcount = prefixSS ["how many words 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"] ;
|
||||||
|
|
||||||
Name x = x ;
|
|
||||||
It = ss "it" ;
|
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" ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
--# -path=.:prelude
|
--# -path=.:prelude
|
||||||
|
|
||||||
concrete UnixUni of Unix = open Prelude in {
|
concrete UnixUni of Unix = CharUni ** open Prelude in {
|
||||||
|
|
||||||
flags unlexer=codelit ; lexer=codelit ;
|
flags unlexer=bind ;
|
||||||
|
|
||||||
{-
|
{-
|
||||||
lincat
|
lincat
|
||||||
@@ -13,6 +13,9 @@ concrete UnixUni of Unix = open Prelude in {
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
lin
|
lin
|
||||||
|
CommWords w = w ;
|
||||||
|
|
||||||
|
Redirect = infixSS ">" ;
|
||||||
Pipe = infixSS "|" ;
|
Pipe = infixSS "|" ;
|
||||||
Comm c = c ;
|
Comm c = c ;
|
||||||
|
|
||||||
@@ -23,8 +26,18 @@ concrete UnixUni of Unix = open Prelude in {
|
|||||||
Copy x y = ss ("cp" ++ x.s ++ y.s) ;
|
Copy x y = ss ("cp" ++ x.s ++ y.s) ;
|
||||||
Linecount = prefixSS ["wc -l"] ;
|
Linecount = prefixSS ["wc -l"] ;
|
||||||
Wordcount = prefixSS ["wc -w"] ;
|
Wordcount = prefixSS ["wc -w"] ;
|
||||||
|
Grep x y = ss ("grep" ++ x.s ++ y.s) ;
|
||||||
|
Cat = prefixSS "cat" ;
|
||||||
|
|
||||||
Name x = x ;
|
|
||||||
It = ss [] ;
|
It = ss [] ;
|
||||||
|
|
||||||
|
FileChars c = c ;
|
||||||
|
WordChars c = c ;
|
||||||
|
|
||||||
|
FileSuffix = prefixSS ["* &+"] ;
|
||||||
|
FilePrefix = postfixSS ["&+ *"] ;
|
||||||
|
|
||||||
|
BaseWord w = w ;
|
||||||
|
ConsWord = cc2 ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user