summaryrefslogtreecommitdiff
path: root/examples/unix/UnixEng.gf
blob: 5b0ca944fe1559ad3547333486b7763812f7db6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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" ;

}