summaryrefslogtreecommitdiff
path: root/src/GF/Source/AbsGF.hs
blob: 37c0e5c528064ada18e21726e6c89a017e42cea5 (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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
module GF.Source.AbsGF where

-- Haskell module generated by the BNF converter

import qualified Data.ByteString.Char8 as BS
newtype LString = LString BS.ByteString deriving (Eq,Ord,Show)
newtype PIdent = PIdent ((Int,Int),BS.ByteString) deriving (Eq,Ord,Show)
data Grammar =
   Gr [ModDef]
  deriving (Eq,Ord,Show)

data ModDef =
   MMain PIdent PIdent [ConcSpec]
 | MModule ComplMod ModType ModBody
  deriving (Eq,Ord,Show)

data ConcSpec =
   ConcSpec PIdent ConcExp
  deriving (Eq,Ord,Show)

data ConcExp =
   ConcExp PIdent [Transfer]
  deriving (Eq,Ord,Show)

data Transfer =
   TransferIn Open
 | TransferOut Open
  deriving (Eq,Ord,Show)

data ModHeader =
   MModule2 ComplMod ModType ModHeaderBody
  deriving (Eq,Ord,Show)

data ModHeaderBody =
   MBody2 Extend Opens
 | MNoBody2 [Included]
 | MWith2 Included [Open]
 | MWithBody2 Included [Open] Opens
 | MWithE2 [Included] Included [Open]
 | MWithEBody2 [Included] Included [Open] Opens
 | MReuse2 PIdent
 | MUnion2 [Included]
  deriving (Eq,Ord,Show)

data ModType =
   MTAbstract PIdent
 | MTResource PIdent
 | MTInterface PIdent
 | MTConcrete PIdent PIdent
 | MTInstance PIdent PIdent
 | MTTransfer PIdent Open Open
  deriving (Eq,Ord,Show)

data ModBody =
   MBody Extend Opens [TopDef]
 | MNoBody [Included]
 | MWith Included [Open]
 | MWithBody Included [Open] Opens [TopDef]
 | MWithE [Included] Included [Open]
 | MWithEBody [Included] Included [Open] Opens [TopDef]
 | MReuse PIdent
 | MUnion [Included]
  deriving (Eq,Ord,Show)

data Extend =
   Ext [Included]
 | NoExt
  deriving (Eq,Ord,Show)

data Opens =
   NoOpens
 | OpenIn [Open]
  deriving (Eq,Ord,Show)

data Open =
   OName PIdent
 | OQualQO QualOpen PIdent
 | OQual QualOpen PIdent PIdent
  deriving (Eq,Ord,Show)

data ComplMod =
   CMCompl
 | CMIncompl
  deriving (Eq,Ord,Show)

data QualOpen =
   QOCompl
 | QOIncompl
 | QOInterface
  deriving (Eq,Ord,Show)

data Included =
   IAll PIdent
 | ISome PIdent [PIdent]
 | IMinus PIdent [PIdent]
  deriving (Eq,Ord,Show)

data Def =
   DDecl [Name] Exp
 | DDef [Name] Exp
 | DPatt Name [Patt] Exp
 | DFull [Name] Exp Exp
  deriving (Eq,Ord,Show)

data TopDef =
   DefCat [CatDef]
 | DefFun [FunDef]
 | DefFunData [FunDef]
 | DefDef [Def]
 | DefData [DataDef]
 | DefTrans [Def]
 | DefPar [ParDef]
 | DefOper [Def]
 | DefLincat [PrintDef]
 | DefLindef [Def]
 | DefLin [Def]
 | DefPrintCat [PrintDef]
 | DefPrintFun [PrintDef]
 | DefFlag [FlagDef]
 | DefPrintOld [PrintDef]
 | DefLintype [Def]
 | DefPattern [Def]
 | DefPackage PIdent [TopDef]
 | DefVars [Def]
 | DefTokenizer PIdent
  deriving (Eq,Ord,Show)

data CatDef =
   SimpleCatDef PIdent [DDecl]
 | ListCatDef PIdent [DDecl]
 | ListSizeCatDef PIdent [DDecl] Integer
  deriving (Eq,Ord,Show)

data FunDef =
   FunDef [PIdent] Exp
  deriving (Eq,Ord,Show)

data DataDef =
   DataDef PIdent [DataConstr]
  deriving (Eq,Ord,Show)

data DataConstr =
   DataId PIdent
 | DataQId PIdent PIdent
  deriving (Eq,Ord,Show)

data ParDef =
   ParDefDir PIdent [ParConstr]
 | ParDefIndir PIdent PIdent
 | ParDefAbs PIdent
  deriving (Eq,Ord,Show)

data ParConstr =
   ParConstr PIdent [DDecl]
  deriving (Eq,Ord,Show)

data PrintDef =
   PrintDef [Name] Exp
  deriving (Eq,Ord,Show)

data FlagDef =
   FlagDef PIdent PIdent
  deriving (Eq,Ord,Show)

data Name =
   IdentName PIdent
 | ListName PIdent
  deriving (Eq,Ord,Show)

data LocDef =
   LDDecl [PIdent] Exp
 | LDDef [PIdent] Exp
 | LDFull [PIdent] Exp Exp
  deriving (Eq,Ord,Show)

data Exp =
   EIdent PIdent
 | EConstr PIdent
 | ECons PIdent
 | ESort Sort
 | EString String
 | EInt Integer
 | EFloat Double
 | EMeta
 | EEmpty
 | EData
 | EList PIdent Exps
 | EStrings String
 | ERecord [LocDef]
 | ETuple [TupleComp]
 | EIndir PIdent
 | ETyped Exp Exp
 | EProj Exp Label
 | EQConstr PIdent PIdent
 | EQCons PIdent PIdent
 | EApp Exp Exp
 | ETable [Case]
 | ETTable Exp [Case]
 | EVTable Exp [Exp]
 | ECase Exp [Case]
 | EVariants [Exp]
 | EPre Exp [Altern]
 | EStrs [Exp]
 | EConAt PIdent Exp
 | EPatt Patt
 | EPattType Exp
 | ESelect Exp Exp
 | ETupTyp Exp Exp
 | EExtend Exp Exp
 | EGlue Exp Exp
 | EConcat Exp Exp
 | EVariant Exp Exp
 | EAbstr [Bind] Exp
 | ECTable [Bind] Exp
 | EProd Decl Exp
 | ETType Exp Exp
 | ELet [LocDef] Exp
 | ELetb [LocDef] Exp
 | EWhere Exp [LocDef]
 | EEqs [Equation]
 | EExample Exp String
 | ELString LString
 | ELin PIdent
  deriving (Eq,Ord,Show)

data Exps =
   NilExp
 | ConsExp Exp Exps
  deriving (Eq,Ord,Show)

data Patt =
   PChar
 | PChars String
 | PMacro PIdent
 | PM PIdent PIdent
 | PW
 | PV PIdent
 | PCon PIdent
 | PQ PIdent PIdent
 | PInt Integer
 | PFloat Double
 | PStr String
 | PR [PattAss]
 | PTup [PattTupleComp]
 | PC PIdent [Patt]
 | PQC PIdent PIdent [Patt]
 | PDisj Patt Patt
 | PSeq Patt Patt
 | PRep Patt
 | PAs PIdent Patt
 | PNeg Patt
  deriving (Eq,Ord,Show)

data PattAss =
   PA [PIdent] Patt
  deriving (Eq,Ord,Show)

data Label =
   LIdent PIdent
 | LVar Integer
  deriving (Eq,Ord,Show)

data Sort =
   Sort_Type
 | Sort_PType
 | Sort_Tok
 | Sort_Str
 | Sort_Strs
  deriving (Eq,Ord,Show)

data Bind =
   BIdent PIdent
 | BWild
  deriving (Eq,Ord,Show)

data Decl =
   DDec [Bind] Exp
 | DExp Exp
  deriving (Eq,Ord,Show)

data TupleComp =
   TComp Exp
  deriving (Eq,Ord,Show)

data PattTupleComp =
   PTComp Patt
  deriving (Eq,Ord,Show)

data Case =
   Case Patt Exp
  deriving (Eq,Ord,Show)

data Equation =
   Equ [Patt] Exp
  deriving (Eq,Ord,Show)

data Altern =
   Alt Exp Exp
  deriving (Eq,Ord,Show)

data DDecl =
   DDDec [Bind] Exp
 | DDExp Exp
  deriving (Eq,Ord,Show)

data OldGrammar =
   OldGr Include [TopDef]
  deriving (Eq,Ord,Show)

data Include =
   NoIncl
 | Incl [FileName]
  deriving (Eq,Ord,Show)

data FileName =
   FString String
 | FIdent PIdent
 | FSlash FileName
 | FDot FileName
 | FMinus FileName
 | FAddId PIdent FileName
  deriving (Eq,Ord,Show)