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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
----------------------------------------------------------------------
-- |
-- Module : MoreCustom
-- Maintainer : AR
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/02/24 11:46:39 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.5 $
--
-- databases for customizable commands. AR 21\/11\/2001
--
-- Extends "Custom".
--
-- obsolete???
-----------------------------------------------------------------------------
module MoreCustom where
import Operations
import Text
import Tokenize
import UseGrammar
import qualified UseSyntax as S
import ShellState
import Editing
import Paraphrases
import Option
import CF
import CFIdent --- (CFTok, tS)
import EBNF
import CFtoGrammar
import PPrCF
import CFtoHappy
import Morphology
import GrammarToHaskell
import GrammarToCanon (showCanon)
import GrammarToXML
import qualified SyntaxToLatex as L
import GFTex
import MkResource
import SeparateOper
-- the cf parsing algorithms
import ChartParser -- or some other CF Parser
import Earley -- such as this one
---- import HappyParser -- or this...
import qualified PPrSRG as SRG
import PPrGSL
import qualified TransPredCalc as PC
-- databases for customizable commands. AR 21/11/2001
-- Extends ../Custom.
moreCustomGrammarParser :: CustomData (FilePath -> IOE C.CanonGrammar)
moreCustomGrammarParser =
[
(strCIm "gfl", S.parseGrammar . extractGFLatex)
,(strCIm "tex", S.parseGrammar . extractGFLatex)
,(strCIm "ebnf", pAsGrammar pEBNFasGrammar)
,(strCIm "cf", pAsGrammar pCFAsGrammar)
-- add your own grammar parsers here
]
where
-- use a parser with no imports or flags
pAsGrammar p = err Bad (\g -> return (([],noOptions),g)) . p
moreCustomGrammarPrinter :: CustomData (StateGrammar -> String)
moreCustomGrammarPrinter =
[
(strCIm "happy", cf2HappyS . stateCF)
,(strCIm "srg", SRG.prSRG . stateCF)
,(strCIm "gsl", prGSL . stateCF)
,(strCIm "gfhs", show . stateGrammarST)
,(strCIm "haskell", grammar2haskell . st2grammar . stateGrammarST)
,(strCIm "xml", unlines . prDTD . grammar2dtd . stateAbstract)
,(strCIm "fullform",prFullForm . stateMorpho)
,(strCIm "resource",prt . st2grammar . mkResourceGrammar . stateGrammarST)
,(strCIm "resourcetypes",
prt . operTypeGrammar . st2grammar . mkResourceGrammar . stateGrammarST)
,(strCIm "resourcedefs",
prt . operDefGrammar . st2grammar . mkResourceGrammar . stateGrammarST)
-- add your own grammar printers here
--- also include printing via grammar2syntax!
]
moreCustomMultiGrammarPrinter :: CustomData (CanonGrammar -> String)
moreCustomMultiGrammarPrinter = []
moreCustomSyntaxPrinter :: CustomData (GF.Grammar -> String)
moreCustomSyntaxPrinter =
[
(strCIm "gf", S.prSyntax) -- DEFAULT
,(strCIm "latex", L.syntax2latexfile)
-- add your own grammar printers here
]
moreCustomTermPrinter :: CustomData (StateGrammar -> Tree -> String)
moreCustomTermPrinter =
[
(strCIm "xml", \g t -> unlines $ prElementX $ term2elemx (stateAbstract g) t)
-- add your own term printers here
]
moreCustomTermCommand :: CustomData (StateGrammar -> Tree -> [Tree])
moreCustomTermCommand =
[
(strCIm "predcalc", \_ t -> PC.transfer t)
-- add your own term commands here
]
moreCustomEditCommand :: CustomData (StateGrammar -> Action)
moreCustomEditCommand =
[
-- add your own edit commands here
]
moreCustomStringCommand :: CustomData (StateGrammar -> String -> String)
moreCustomStringCommand =
[
-- add your own string commands here
]
moreCustomParser :: CustomData (StateGrammar -> CFCat -> CFParser)
moreCustomParser =
[
(strCIm "chart", chartParser . stateCF)
,(strCIm "earley", earleyParser . stateCF)
-- ,(strCIm "happy", const $ lexHaskell)
-- ,(strCIm "td", const $ lexText)
-- add your own parsers here
]
moreCustomTokenizer :: CustomData (StateGrammar -> String -> [CFTok])
moreCustomTokenizer =
[
-- add your own tokenizers here
]
moreCustomUntokenizer :: CustomData (StateGrammar -> String -> String)
moreCustomUntokenizer =
[
-- add your own untokenizers here
]
moreCustomUniCoding :: CustomData (String -> String)
moreCustomUniCoding =
[
-- add your own codings here
]
strCIm :: String -> CommandId
strCIm = id
|