]> Joshua Wise's Git repositories - snipe.git/blame - parse/l1.lex.sml
Initial import of l1c
[snipe.git] / parse / l1.lex.sml
CommitLineData
12aa4087
JW
1functor L1LexFn(structure Tokens : L1_TOKENS)=
2 struct
3 structure UserDeclarations =
4 struct
5(* L1 Compiler
6 * Lexer
7 * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
8 * Modified: Frank Pfenning <fp@cs.cmu.edu>
9 *)
10
11structure A = Ast
12structure S = Symbol
13
14type pos = int
15type svalue = Tokens.svalue
16type ('a,'b) token = ('a,'b) Tokens.token
17type lexresult = (svalue,pos) Tokens.token
18
19local
20 val commentLevel = ref 0
21 val commentPos = ref 0
22in
23 fun enterComment yypos =
24 ( commentLevel := !commentLevel + 1 ;
25 commentPos := yypos )
26
27 fun exitComment () =
28 ( commentLevel := !commentLevel - 1 ;
29 !commentLevel = 0 )
30
31 fun number (yyt, yyp) =
32 let
33 val ext = ParseState.ext (yyp, yyp + size yyt)
34 val numOpt = Word32Signed.fromString yyt
35 handle Overflow =>
36 ( ErrorMsg.error ext
37 ("integral constant `" ^ yyt ^ "' too large") ;
38 NONE )
39 in
40 case numOpt
41 of NONE => ( ErrorMsg.error ext
42 ("cannot parse integral constant `" ^ yyt ^ "'");
43 Tokens.INTNUM (Word32Signed.ZERO, yyp, yyp + size yyt) )
44 | SOME n => Tokens.INTNUM (n,yyp,yyp + size yyt)
45 end
46
47 fun eof () =
48 ( if (!commentLevel > 0)
49 then (ErrorMsg.error (ParseState.ext (!commentPos,!commentPos)) "unterminated comment")
50 else ();
51 Tokens.EOF (0,0) ) (* bogus position information; unused *)
52
53end
54
55end (* end of user routines *)
56exception LexError (* raised if illegal leaf action tried *)
57structure Internal =
58 struct
59
60datatype yyfinstate = N of int
61type statedata = {fin : yyfinstate list, trans: string}
62(* transition & final state table *)
63val tab = let
64val s = [
65 (0,
66"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
67\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
68\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
69\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
70\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
71\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
72\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
73\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
74\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
75\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
76\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
77\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
78\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
79\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
80\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
81\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
82),
83 (1,
84"\007\007\007\007\007\007\007\007\007\038\040\007\038\007\007\007\
85\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
86\\038\007\007\037\007\035\007\007\034\033\030\028\007\026\007\022\
87\\020\020\020\020\020\020\020\020\020\020\007\019\007\018\007\007\
88\\007\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\
89\\010\010\010\010\010\010\010\010\010\010\010\007\007\007\007\010\
90\\007\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\
91\\010\010\012\010\010\010\010\010\010\010\010\009\007\008\007\007\
92\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
93\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
94\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
95\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
96\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
97\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
98\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\
99\\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007\007"
100),
101 (3,
102"\041\041\041\041\041\041\041\041\041\041\046\041\041\041\041\041\
103\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
104\\041\041\041\041\041\041\041\041\041\041\044\041\041\041\041\042\
105\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
106\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
107\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
108\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
109\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
110\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
111\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
112\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
113\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
114\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
115\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
116\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\
117\\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041\041"
118),
119 (5,
120"\047\047\047\047\047\047\047\047\047\047\048\047\047\047\047\047\
121\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
122\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
123\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
124\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
125\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
126\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
127\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
128\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
129\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
130\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
131\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
132\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
133\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
134\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\
135\\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047\047"
136),
137 (10,
138"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
139\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
140\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
141\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
142\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
143\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
144\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
145\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\
146\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
147\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
148\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
149\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
150\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
151\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
152\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
153\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
154),
155 (12,
156"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
157\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
158\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
159\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
160\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
161\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
162\\000\011\011\011\011\013\011\011\011\011\011\011\011\011\011\011\
163\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\
164\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
165\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
166\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
167\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
168\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
169\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
170\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
171\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
172),
173 (13,
174"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
175\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
176\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
177\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
178\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
179\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
180\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
181\\011\011\011\011\014\011\011\011\011\011\011\000\000\000\000\000\
182\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
183\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
184\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
185\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
186\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
187\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
188\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
189\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
190),
191 (14,
192"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
193\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
194\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
195\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
196\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
197\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
198\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
199\\011\011\011\011\011\015\011\011\011\011\011\000\000\000\000\000\
200\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
201\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
202\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
203\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
204\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
205\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
206\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
207\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
208),
209 (15,
210"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
211\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
212\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
213\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
214\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
215\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
216\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
217\\011\011\016\011\011\011\011\011\011\011\011\000\000\000\000\000\
218\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
219\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
220\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
221\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
222\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
223\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
224\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
225\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
226),
227 (16,
228"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
229\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
230\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
231\\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\000\
232\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\011\011\
233\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\011\
234\\000\011\011\011\011\011\011\011\011\011\011\011\011\011\017\011\
235\\011\011\011\011\011\011\011\011\011\011\011\000\000\000\000\000\
236\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
237\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
238\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
239\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
240\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
241\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
242\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
243\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
244),
245 (20,
246"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
247\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
248\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
249\\021\021\021\021\021\021\021\021\021\021\000\000\000\000\000\000\
250\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
251\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
252\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
253\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
254\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
255\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
256\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
257\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
258\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
259\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
260\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
261\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
262),
263 (22,
264"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
265\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
266\\000\000\000\000\000\000\000\000\000\000\025\000\000\000\000\024\
267\\000\000\000\000\000\000\000\000\000\000\000\000\000\023\000\000\
268\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
269\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
270\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
271\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
272\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
273\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
274\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
275\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
276\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
277\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
278\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
279\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
280),
281 (26,
282"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
283\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
284\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
285\\000\000\000\000\000\000\000\000\000\000\000\000\000\027\000\000\
286\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
287\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
288\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
289\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
290\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
291\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
292\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
293\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
294\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
295\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
296\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
297\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
298),
299 (28,
300"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
301\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
302\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
303\\000\000\000\000\000\000\000\000\000\000\000\000\000\029\000\000\
304\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
305\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
306\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
307\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
308\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
309\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
310\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
311\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
312\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
313\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
314\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
315\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
316),
317 (30,
318"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
319\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
320\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\032\
321\\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\000\
322\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
323\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
324\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
325\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
326\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
327\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
328\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
329\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
330\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
331\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
332\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
333\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
334),
335 (35,
336"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
337\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
338\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
339\\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\000\
340\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
341\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
342\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
343\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
344\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
345\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
346\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
347\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
348\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
349\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
350\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
351\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
352),
353 (38,
354"\000\000\000\000\000\000\000\000\000\039\000\000\039\000\000\000\
355\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
356\\039\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
357\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
358\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
359\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
360\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
361\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
362\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
363\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
364\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
365\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
366\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
367\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
368\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
369\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
370),
371 (42,
372"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
373\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
374\\000\000\000\000\000\000\000\000\000\000\043\000\000\000\000\000\
375\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
376\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
377\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
378\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
379\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
380\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
381\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
382\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
383\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
384\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
385\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
386\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
387\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
388),
389 (44,
390"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
391\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
392\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\
393\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
394\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
395\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
396\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
397\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
398\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
399\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
400\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
401\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
402\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
403\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
404\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\
405\\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
406),
407(0, "")]
408fun f x = x
409val s = map f (rev (tl (rev s)))
410exception LexHackingError
411fun look ((j,x)::r, i: int) = if i = j then x else look(r, i)
412 | look ([], i) = raise LexHackingError
413fun g {fin=x, trans=i} = {fin=x, trans=look(s,i)}
414in Vector.fromList(map g
415[{fin = [], trans = 0},
416{fin = [], trans = 1},
417{fin = [], trans = 1},
418{fin = [], trans = 3},
419{fin = [], trans = 3},
420{fin = [], trans = 5},
421{fin = [], trans = 5},
422{fin = [(N 67)], trans = 0},
423{fin = [(N 8),(N 67)], trans = 0},
424{fin = [(N 6),(N 67)], trans = 0},
425{fin = [(N 54),(N 67)], trans = 10},
426{fin = [(N 54)], trans = 10},
427{fin = [(N 54),(N 67)], trans = 12},
428{fin = [(N 54)], trans = 13},
429{fin = [(N 54)], trans = 14},
430{fin = [(N 54)], trans = 15},
431{fin = [(N 54)], trans = 16},
432{fin = [(N 48),(N 54)], trans = 10},
433{fin = [(N 16),(N 67)], trans = 0},
434{fin = [(N 14),(N 67)], trans = 0},
435{fin = [(N 51),(N 67)], trans = 20},
436{fin = [(N 51)], trans = 20},
437{fin = [(N 39),(N 67)], trans = 22},
438{fin = [(N 28)], trans = 0},
439{fin = [(N 63)], trans = 0},
440{fin = [(N 57)], trans = 0},
441{fin = [(N 35),(N 67)], trans = 26},
442{fin = [(N 22)], trans = 0},
443{fin = [(N 33),(N 67)], trans = 28},
444{fin = [(N 19)], trans = 0},
445{fin = [(N 37),(N 67)], trans = 30},
446{fin = [(N 25)], trans = 0},
447{fin = [(N 60)], trans = 0},
448{fin = [(N 12),(N 67)], trans = 0},
449{fin = [(N 10),(N 67)], trans = 0},
450{fin = [(N 41),(N 67)], trans = 35},
451{fin = [(N 31)], trans = 0},
452{fin = [(N 65),(N 67)], trans = 0},
453{fin = [(N 2),(N 67)], trans = 38},
454{fin = [(N 2)], trans = 38},
455{fin = [(N 4)], trans = 0},
456{fin = [(N 77)], trans = 0},
457{fin = [(N 77)], trans = 42},
458{fin = [(N 70)], trans = 0},
459{fin = [(N 77)], trans = 44},
460{fin = [(N 73)], trans = 0},
461{fin = [(N 75)], trans = 0},
462{fin = [(N 81)], trans = 0},
463{fin = [(N 79)], trans = 0}])
464end
465structure StartStates =
466 struct
467 datatype yystartstate = STARTSTATE of int
468
469(* start state definitions *)
470
471val COMMENT = STARTSTATE 3;
472val COMMENT_LINE = STARTSTATE 5;
473val INITIAL = STARTSTATE 1;
474
475end
476type result = UserDeclarations.lexresult
477 exception LexerError (* raised if illegal leaf action tried *)
478end
479
480fun makeLexer yyinput =
481let val yygone0=1
482 val yyb = ref "\n" (* buffer *)
483 val yybl = ref 1 (*buffer length *)
484 val yybufpos = ref 1 (* location of next character to use *)
485 val yygone = ref yygone0 (* position in file of beginning of buffer *)
486 val yydone = ref false (* eof found yet? *)
487 val yybegin = ref 1 (*Current 'start state' for lexer *)
488
489 val YYBEGIN = fn (Internal.StartStates.STARTSTATE x) =>
490 yybegin := x
491
492fun lex () : Internal.result =
493let fun continue() = lex() in
494 let fun scan (s,AcceptingLeaves : Internal.yyfinstate list list,l,i0) =
495 let fun action (i,nil) = raise LexError
496 | action (i,nil::l) = action (i-1,l)
497 | action (i,(node::acts)::l) =
498 case node of
499 Internal.N yyk =>
500 (let fun yymktext() = substring(!yyb,i0,i-i0)
501 val yypos = i0+ !yygone
502 open UserDeclarations Internal.StartStates
503 in (yybufpos := i; case yyk of
504
505 (* Application actions *)
506
507 10 => let val yytext=yymktext() in Tokens.LPAREN (yypos, yypos + size yytext) end
508| 12 => let val yytext=yymktext() in Tokens.RPAREN (yypos, yypos + size yytext) end
509| 14 => let val yytext=yymktext() in Tokens.SEMI (yypos, yypos + size yytext) end
510| 16 => let val yytext=yymktext() in Tokens.ASSIGN (yypos, yypos + size yytext) end
511| 19 => let val yytext=yymktext() in Tokens.PLUSEQ (yypos, yypos + size yytext) end
512| 2 => (lex ())
513| 22 => let val yytext=yymktext() in Tokens.MINUSEQ (yypos, yypos + size yytext) end
514| 25 => let val yytext=yymktext() in Tokens.STAREQ (yypos, yypos + size yytext) end
515| 28 => let val yytext=yymktext() in Tokens.SLASHEQ (yypos, yypos + size yytext) end
516| 31 => let val yytext=yymktext() in Tokens.PERCENTEQ (yypos, yypos + size yytext) end
517| 33 => let val yytext=yymktext() in Tokens.PLUS (yypos, yypos + size yytext) end
518| 35 => let val yytext=yymktext() in Tokens.MINUS (yypos, yypos + size yytext) end
519| 37 => let val yytext=yymktext() in Tokens.STAR (yypos, yypos + size yytext) end
520| 39 => let val yytext=yymktext() in Tokens.SLASH (yypos, yypos + size yytext) end
521| 4 => (ParseState.newline(yypos); lex())
522| 41 => let val yytext=yymktext() in Tokens.PERCENT (yypos, yypos + size yytext) end
523| 48 => let val yytext=yymktext() in Tokens.RETURN (yypos, yypos + size yytext) end
524| 51 => let val yytext=yymktext() in number (yytext, yypos) end
525| 54 => let val yytext=yymktext() in let
526 val id = Symbol.symbol yytext
527 in
528 Tokens.IDENT (id, yypos, yypos + size yytext)
529 end end
530| 57 => (YYBEGIN COMMENT; enterComment yypos; lex())
531| 6 => let val yytext=yymktext() in Tokens.LBRACE (yypos, yypos + size yytext) end
532| 60 => (ErrorMsg.error (ParseState.ext (yypos, yypos)) "unbalanced comments";
533 lex())
534| 63 => (YYBEGIN COMMENT_LINE; lex())
535| 65 => (YYBEGIN COMMENT_LINE; lex())
536| 67 => let val yytext=yymktext() in ErrorMsg.error (ParseState.ext (yypos,yypos))
537 ("illegal character: \"" ^ yytext ^ "\"");
538 lex () end
539| 70 => (enterComment yypos; lex())
540| 73 => (if exitComment () then YYBEGIN INITIAL else (); lex())
541| 75 => (ParseState.newline yypos; lex ())
542| 77 => (lex())
543| 79 => (ParseState.newline yypos; YYBEGIN INITIAL; lex())
544| 8 => let val yytext=yymktext() in Tokens.RBRACE (yypos, yypos + size yytext) end
545| 81 => (lex())
546| _ => raise Internal.LexerError
547
548 ) end )
549
550 val {fin,trans} = Unsafe.Vector.sub(Internal.tab, s)
551 val NewAcceptingLeaves = fin::AcceptingLeaves
552 in if l = !yybl then
553 if trans = #trans(Vector.sub(Internal.tab,0))
554 then action(l,NewAcceptingLeaves
555) else let val newchars= if !yydone then "" else yyinput 1024
556 in if (size newchars)=0
557 then (yydone := true;
558 if (l=i0) then UserDeclarations.eof ()
559 else action(l,NewAcceptingLeaves))
560 else (if i0=l then yyb := newchars
561 else yyb := substring(!yyb,i0,l-i0)^newchars;
562 yygone := !yygone+i0;
563 yybl := size (!yyb);
564 scan (s,AcceptingLeaves,l-i0,0))
565 end
566 else let val NewChar = Char.ord(Unsafe.CharVector.sub(!yyb,l))
567 val NewState = Char.ord(Unsafe.CharVector.sub(trans,NewChar))
568 in if NewState=0 then action(l,NewAcceptingLeaves)
569 else scan(NewState,NewAcceptingLeaves,l+1,i0)
570 end
571 end
572(*
573 val start= if substring(!yyb,!yybufpos-1,1)="\n"
574then !yybegin+1 else !yybegin
575*)
576 in scan(!yybegin (* start *),nil,!yybufpos,!yybufpos)
577 end
578end
579 in lex
580 end
581end
This page took 0.067084 seconds and 4 git commands to generate.