1%%
2%name SML
3%eop EOF
4%term ABSTYPE | AND | ANDALSO | AS | CASE | DATATYPE | DO | ELSE | END
5    | EQTYPE | EXCEPTION | FN | FUN | HANDLE | IF | IN | INFIX | INFIXR
6    | LET | LOCAL | NONFIX | OF | OP | ORELSE | RAISE | REC | SIG | SIGNATURE
7    | STRUCT | STRUCTURE | THEN | TYPE | VAL | WHILE | WITH | WITHTYPE | WHERE
8    | EQUALS | COMMA | ARROW | DARROW | BAR | STAR | HASH | LBRACE | RBRACE
9    | HASHLBRACKET | LBRACKET | RBRACKET | LPAREN | RPAREN | COLON | SEMICOLON
10    | UNDERBAR | DOTDOTDOT | OPEN | INCLUDE | PRIM_VAL | PRIM_TYPE
11    | PRIM_EQTYPE | PRIM_REFTYPE | EOF
12    | ID of string
13    | QUAL_ID of Asynt.QualifiedIdent
14    | QUAL_STAR of Asynt.QualifiedIdent
15    | ZDIGIT of int
16    | NZDIGIT of int
17    | ZPOSINT2 of int
18    | NZPOSINT2 of int
19    | NEGINT of int
20    | WORD of word
21    | CHAR of char
22    | REAL of real
23    | STRING of string
24    | QUOTEL
25    | QUOTER of string
26    | QUOTEM of string
27    | TYVAR of string
28
29%keyword AND INCLUDE VAL EXCEPTION WITH WHERE
30
31%verbose
32%right    AND
33%nonassoc DARROW
34%nonassoc BAR
35%nonassoc ELSE
36%nonassoc DO
37%nonassoc RAISE
38%right    HANDLE
39%right    ORELSE
40%right    ANDALSO
41%right    AS
42
43%nonassoc COLON
44%right    ARROW
45%nonassoc ID EQUALS
46%right    STAR
47
48%start SigFile
49%nonterm SigFile of Asynt.Sig
50       | Ident of string
51       | EqIdent of string
52       | IdentWithLoc of Asynt.Location * string
53       | LocUnitName of Asynt.Location * string
54       | ModId of Asynt.Location * string
55       | ModId_seq1 of (Asynt.Location * string) list
56       | ModId_seq2 of (Asynt.Location * string) list
57       | OpIdent of Asynt.IdInfo
58       | OpEqIdent of Asynt.IdInfo
59       | TypeIdent of Asynt.IdInfo
60       | LongTypeIdent of Asynt.IdInfo
61       | TyVar of Asynt.TyVar
62       | NumLabel of int
63       | Arity of int
64       | SemiEof of unit
65       | Label of Asynt.Lab
66       | PrimValBind of Asynt.PrimValBind list
67       | AndPrimValBind_opt of Asynt.PrimValBind list
68       | TypBind of Asynt.TypBind list
69       | SigModTypBind of Asynt.TypBind list
70       | AndTypBind_opt of Asynt.TypBind list
71       | TypDesc of Asynt.TypDesc list
72       | AndTypDesc_opt of Asynt.TypDesc list
73       | DatBind of Asynt.DatBind list
74       | DatBind_0 of Asynt.DatBind list
75       | DatBind_n of Asynt.DatBind list
76       | AndDatBind_opt of Asynt.DatBind list
77       | ConBind of Asynt.ConBind list
78       | BarConBind_opt of Asynt.ConBind list
79       | WithType_opt of Asynt.TypBind list option
80       | ExDesc of Asynt.ExDesc list
81       | AndExDesc_opt of Asynt.ExDesc list
82       | OfTy_opt of Asynt.Ty option
83       | Ty of Asynt.Ty
84       | Ty_sans_STAR of Asynt.Ty
85       | AtomicTy of Asynt.Ty
86       | TupleTy of Asynt.Ty list
87       | TyComma_seq2 of Asynt.Ty list
88       | TyRow_opt of Asynt.Ty Asynt.Row
89       | TyRow of Asynt.Ty Asynt.Row
90       | CommaTyRow_opt of Asynt.Ty Asynt.Row
91       | TyVarSeq of Asynt.TyVar list
92       | TyVarSeq1 of Asynt.TyVar list
93       | TyVarComma_seq1 of Asynt.TyVar list
94       | Spec of Asynt.Spec
95       | KWSpec of Asynt.Spec
96       | KWSpec_seq of Asynt.Spec list
97       | ValDesc of Asynt.ValDesc list
98       | AndValDesc_opt of Asynt.ValDesc list
99       | ModDesc of Asynt.ModDesc
100       | SigExp of Asynt.SigExp
101%pos (int * int)
102%pure
103%%
104
105Ident :
106    ID          ( ID )
107  | STAR        ( "*" )
108
109IdentWithLoc :
110    Ident       ( ((Identleft, Identright), Ident) )
111
112OpIdent :
113    Ident       ( Asynt.mkIdInfo ((Identleft, Identright), { qual="", id=Ident }) false )
114  | OP Ident    ( Asynt.mkIdInfo ((OPleft, Identright), { qual="", id=Ident }) true )
115
116OpEqIdent :
117    EqIdent     ( Asynt.mkIdInfo ((EqIdentleft, EqIdentright), { qual="", id=EqIdent }) false )
118  | OP Ident    ( Asynt.mkIdInfo ((OPleft, Identright), { qual="", id=Ident }) true )
119
120EqIdent :
121    Ident       ( Ident )
122  | EQUALS      ( "=" )
123
124LocUnitName :
125    IdentWithLoc ( IdentWithLoc )
126
127TypeIdent :
128    ID          ( Asynt.mkIdInfo ((IDleft, IDright), { qual="", id=ID }) false )
129
130LongTypeIdent :
131    TypeIdent   ( TypeIdent )
132  | QUAL_ID     ( Asynt.mkIdInfo ((QUAL_IDleft, QUAL_IDright), QUAL_ID) false )
133
134TyVar :
135    TYVAR    ( Asynt.mkIdInfo ((TYVARleft, TYVARright), { qual="", id=TYVAR }) false )
136
137NumLabel :
138    NZPOSINT2   ( NZPOSINT2 )
139  | NZDIGIT     ( NZDIGIT )
140
141Label :
142    Ident       ( Asynt.STRINGlab Ident )
143  | NumLabel    ( Asynt.INTlab NumLabel )
144
145Arity :
146    ZPOSINT2    ( ZPOSINT2 )
147  | NZPOSINT2   ( NZPOSINT2 )
148  | ZDIGIT      ( ZDIGIT )
149  | NZDIGIT     ( NZDIGIT )
150
151SemiEof :
152    SEMICOLON SemiEof   ( )
153  | EOF			( )
154
155PrimValBind :
156    OpIdent COLON Ty EQUALS Arity STRING AndPrimValBind_opt
157                        ( (OpIdent, Ty, Arity, STRING) :: AndPrimValBind_opt )
158
159AndPrimValBind_opt :
160    AND PrimValBind     ( PrimValBind )
161  | (* *)               ( [] )
162
163TypBind :
164    TyVarSeq TypeIdent  EQUALS Ty AndTypBind_opt
165                        ( (TyVarSeq, TypeIdent, Ty) :: AndTypBind_opt )
166
167AndTypBind_opt :
168    AND TypBind         ( TypBind )
169  | (* *)               ( [] )
170
171DatBind_0 :
172    TypeIdent EQUALS ConBind AndDatBind_opt
173                        ( ([], TypeIdent, ConBind) :: AndDatBind_opt )
174
175DatBind_n :
176    TyVarSeq1 TypeIdent EQUALS ConBind AndDatBind_opt
177                        ( (TyVarSeq1, TypeIdent, ConBind) :: AndDatBind_opt )
178
179DatBind :
180    TyVarSeq TypeIdent EQUALS ConBind AndDatBind_opt
181                        ( (TyVarSeq, TypeIdent, ConBind) :: AndDatBind_opt )
182
183AndDatBind_opt :
184    AND DatBind         ( DatBind )
185  | (* *)               ( [] )
186
187ConBind :
188    OpIdent OfTy_opt BarConBind_opt     ( Asynt.ConBind(OpIdent, OfTy_opt) :: BarConBind_opt )
189
190BarConBind_opt :
191    BAR ConBind         ( ConBind )
192  | (* *)               ( [] )
193
194WithType_opt :
195    WITHTYPE TypBind    ( SOME TypBind )
196  | (* *)               ( NONE )
197
198ExDesc :
199    OpIdent OfTy_opt AndExDesc_opt              ( (OpIdent,OfTy_opt) :: AndExDesc_opt )
200
201AndExDesc_opt :
202    AND ExDesc          ( ExDesc )
203  | (* *)               ( [] )
204
205OfTy_opt :
206    OF Ty       ( SOME Ty )
207  | (* *)       ( NONE )
208
209Ty :
210    TupleTy ARROW Ty    ( ((TupleTyleft, Tyright), Asynt.FNty( Asynt.tupleTy TupleTy, Ty)) )
211  | TupleTy             ( (Asynt.tupleTy TupleTy) )
212
213TupleTy :
214    Ty_sans_STAR                ( [Ty_sans_STAR] )
215  | Ty_sans_STAR STAR TupleTy   ( Ty_sans_STAR :: TupleTy )
216
217Ty_sans_STAR :
218    LPAREN TyComma_seq2 RPAREN LongTypeIdent    ( ((LPARENleft, LongTypeIdentright), Asynt.CONty(TyComma_seq2, LongTypeIdent)) )
219  | Ty_sans_STAR LongTypeIdent                  ( ((Ty_sans_STARleft, LongTypeIdentright), Asynt.CONty([Ty_sans_STAR], LongTypeIdent)) )
220  | AtomicTy                                    ( AtomicTy )
221
222TyComma_seq2 :
223    Ty COMMA TyComma_seq2       ( Ty :: TyComma_seq2 )
224  | Ty COMMA Ty                 ( [Ty1, Ty2] )
225
226AtomicTy :
227    LongTypeIdent               ( ((LongTypeIdentleft, LongTypeIdentleft), Asynt.CONty([], LongTypeIdent)) )
228  | TyVar                       ( ((TyVarleft, TyVarright), Asynt.TYVARty TyVar) )
229  | LBRACE TyRow_opt RBRACE     ( ((LBRACEleft, LBRACEright), Asynt.RECty TyRow_opt) )
230  | LPAREN Ty RPAREN            ( Ty )
231
232TyRow_opt :
233    TyRow       ( TyRow )
234  | (* *)       ( [] )
235
236TyRow :
237    Label COLON Ty CommaTyRow_opt       ( (Label,Ty)::CommaTyRow_opt )
238
239CommaTyRow_opt :
240    COMMA TyRow         ( TyRow )
241  | (* *)               ( [] )
242
243TyVarSeq :
244    TyVarSeq1                           ( TyVarSeq1 )
245  | (* *)                               ( [] )
246
247TyVarSeq1 :
248    TyVar                               ( [TyVar] )
249  | LPAREN TyVarComma_seq1 RPAREN       ( TyVarComma_seq1 )
250
251TyVarComma_seq1 :
252    TyVar COMMA TyVarComma_seq1         ( TyVar :: TyVarComma_seq1 )
253  | TyVar                               ( [TyVar] )
254
255SigFile :
256    SIGNATURE LocUnitName EQUALS SIG KWSpec_seq END SemiEof
257                        ( Asynt.NamedSig{locsigid = LocUnitName, specs = KWSpec_seq } )
258  | KWSpec_seq EOF	( Asynt.AnonSig KWSpec_seq )
259
260KWSpec_seq :
261    KWSpec KWSpec_seq		( KWSpec :: KWSpec_seq )
262  | SEMICOLON KWSpec_seq	( KWSpec_seq )
263  | (* *)			( [] )
264
265Spec :
266    KWSpec Spec         ( ((KWSpecleft, Specright), Asynt.SEQspec(KWSpec, Spec)) )
267  | SEMICOLON Spec      ( Spec )
268  | (* *)               ( ((defaultPos, defaultPos), Asynt.EMPTYspec) )
269
270KWSpec :
271    VAL ValDesc                 ( ((VALleft, ValDescright), Asynt.VALspec ValDesc) )
272  | PRIM_VAL PrimValBind        ( ((PRIM_VALleft, PrimValBindright), Asynt.PRIM_VALspec PrimValBind) )
273  | TYPE TypBind                ( ((TYPEleft, TypBindright), Asynt.TYPEspec TypBind) )
274  | TYPE TypDesc                ( ((TYPEleft, TypDescright), Asynt.TYPEDESCspec(Asynt.FALSEequ, TypDesc)) )
275  | EQTYPE TypDesc              ( ((EQTYPEleft, TypDescright), Asynt.TYPEDESCspec(Asynt.TRUEequ, TypDesc)) )
276  | PRIM_REFTYPE TypDesc        ( ((PRIM_REFTYPEleft, TypDescright), Asynt.TYPEDESCspec(Asynt.REFequ, TypDesc)) )
277  | DATATYPE DatBind_0 WithType_opt
278                                ( ((DATATYPEleft, WithType_optright), Asynt.DATATYPEspec(DatBind_0,WithType_opt)) )
279  | DATATYPE DatBind_n WithType_opt
280                                ( ((DATATYPEleft, WithType_optright), Asynt.DATATYPEspec(DatBind_n,WithType_opt)) )
281  | DATATYPE TypeIdent EQUALS DATATYPE LongTypeIdent
282                                ( ((DATATYPEleft, LongTypeIdentright), Asynt.DATATYPErepspec(TypeIdent,LongTypeIdent)))
283  | EXCEPTION ExDesc            ( ((EXCEPTIONleft, ExDescright), Asynt.EXCEPTIONspec ExDesc) )
284  | LOCAL Spec IN Spec END      ( ((LOCALleft, ENDright), Asynt.LOCALspec(Spec1,Spec2)) )
285  | OPEN ModId_seq1          ( ((OPENleft, ModId_seq1right),
286                                Asynt.OPENspec (map #2 ModId_seq1)) )
287  | INCLUDE ModId_seq2       ( ((INCLUDEleft, ModId_seq2right),
288                                Asynt.INCLUDEspecs (map #2 ModId_seq2)) )
289  | INCLUDE SigExp              ( ((INCLUDEleft, SigExpright), Asynt.INCLUDEspec SigExp) )
290  | STRUCTURE ModDesc      ( ((STRUCTUREleft, ModDescright), Asynt.STRUCTUREspec ModDesc))
291
292ValDesc :
293    OpEqIdent COLON Ty AndValDesc_opt
294                        ( (OpEqIdent, Ty) :: AndValDesc_opt )
295
296AndValDesc_opt :
297    AND ValDesc         ( ValDesc )
298  | (* *)               ( [] )
299
300TypDesc :
301    TyVarSeq TypeIdent AndTypDesc_opt
302                        ( (TyVarSeq, TypeIdent) :: AndTypDesc_opt )
303
304AndTypDesc_opt :
305    AND TypDesc         ( TypDesc )
306  | (* *)               ( [] )
307
308ModDesc :
309    ModId COLON SigExp
310                        ( Asynt.MODDESCmoddesc(ModId, SigExp) )
311
312SigExp :
313     ModId          ((ModIdleft, ModIdright), Asynt.SIGIDsigexp ModId, [])
314   | ModId WHERE SigModTypBind
315                    ((ModIdleft, ModIdright),
316                     Asynt.SIGIDsigexp ModId,
317                     SigModTypBind)
318   | SIG KWSpec_seq END
319                    ((SIGleft, ENDright), Asynt.AnonSigThing KWSpec_seq, [])
320
321
322SigModTypBind :
323    TYPE TyVarSeq TypeIdent EQUALS Ty
324                        ( [(TyVarSeq, TypeIdent, Ty)] )
325|   TYPE TyVarSeq TypeIdent EQUALS Ty AND SigModTypBind
326                        ( (TyVarSeq, TypeIdent, Ty) :: SigModTypBind )
327
328ModId :
329    IdentWithLoc       ( IdentWithLoc )
330
331ModId_seq1 :
332    ModId ([ModId])
333|   ModId ModId_seq1 (ModId :: ModId_seq1)
334
335ModId_seq2 :
336    ModId ModId ([ModId1, ModId2])
337|   ModId ModId_seq2 (ModId :: ModId_seq2)
338