@@ -105,7 +105,7 @@ let input_from get_script run =
105
105
true
106
106
with
107
107
| Decode. Code (at , msg ) -> error at " decoding error" msg
108
- | Parse. Syntax (at , msg ) -> error at " syntax error" msg
108
+ | Syntax (at , msg ) -> error at " syntax error" msg
109
109
| Valid. Invalid (at , msg ) -> error at " invalid module" msg
110
110
| Import. Unknown (at , msg ) -> error at " link failure" msg
111
111
| Eval. Link (at , msg ) -> error at " link failure" msg
@@ -118,17 +118,26 @@ let input_from get_script run =
118
118
| Assert (at , msg ) -> error at " assertion failure" msg
119
119
| Abort _ -> false
120
120
121
- let input_script start name lexbuf run =
122
- input_from (fun _ -> Parse. parse name lexbuf start) run
121
+ let input_script name lexbuf run =
122
+ input_from (fun () ->
123
+ Lexing. set_filename lexbuf name;
124
+ Parse.Script. from_lexbuf lexbuf)
125
+ run
126
+
127
+ let input_script1 name lexbuf run =
128
+ input_from (fun () ->
129
+ Lexing. set_filename lexbuf name;
130
+ Parse.Script1. from_lexbuf lexbuf)
131
+ run
123
132
124
133
let input_sexpr name lexbuf run =
125
- input_from (fun _ ->
126
- let var_opt, def = Parse. parse name lexbuf Parse. Module in
134
+ input_from (fun () ->
135
+ let var_opt, def = Parse.Module. from_lexbuf lexbuf in
127
136
[Module (var_opt, def) @@ no_region]) run
128
137
129
138
let input_binary name buf run =
130
139
let open Source in
131
- input_from (fun _ ->
140
+ input_from (fun () ->
132
141
[Module (None , Encoded (name, buf) @@ no_region) @@ no_region]) run
133
142
134
143
let input_sexpr_file input file run =
@@ -162,16 +171,16 @@ let input_file file run =
162
171
dispatch_file_ext
163
172
input_binary_file
164
173
(input_sexpr_file input_sexpr)
165
- (input_sexpr_file ( input_script Parse. Script ) )
166
- (input_sexpr_file ( input_script Parse. Script ) )
174
+ (input_sexpr_file input_script)
175
+ (input_sexpr_file input_script)
167
176
input_js_file
168
177
file run
169
178
170
179
let input_string string run =
171
180
trace (" Running (\" " ^ String. escaped string ^ " \" )..." );
172
181
let lexbuf = Lexing. from_string string in
173
182
trace " Parsing..." ;
174
- input_script Parse. Script " string" lexbuf run
183
+ input_script " string" lexbuf run
175
184
176
185
177
186
(* Interactive *)
@@ -195,7 +204,7 @@ let lexbuf_stdin buf len =
195
204
let input_stdin run =
196
205
let lexbuf = Lexing. from_function lexbuf_stdin in
197
206
let rec loop () =
198
- let success = input_script Parse. Script1 " stdin" lexbuf run in
207
+ let success = input_script1 " stdin" lexbuf run in
199
208
if not success then Lexing. flush_input lexbuf;
200
209
if Lexing. (lexbuf.lex_curr_pos > = lexbuf.lex_buffer_len - 1 ) then
201
210
continuing := false ;
@@ -337,7 +346,7 @@ let rec run_definition def : Ast.module_ =
337
346
Decode. decode name bs
338
347
| Quoted (_ , s ) ->
339
348
trace " Parsing quote..." ;
340
- let def' = Parse. string_to_module s in
349
+ let _, def' = Parse.Module. from_string s in
341
350
run_definition def'
342
351
343
352
let run_action act : Values.value list =
@@ -443,7 +452,7 @@ let run_assertion ass =
443
452
trace " Asserting malformed..." ;
444
453
(match ignore (run_definition def) with
445
454
| exception Decode. Code (_ , msg ) -> assert_message ass.at " decoding" msg re
446
- | exception Parse. Syntax (_ , msg ) -> assert_message ass.at " parsing" msg re
455
+ | exception Syntax (_ , msg ) -> assert_message ass.at " parsing" msg re
447
456
| _ -> Assert. error ass.at " expected decoding/parsing error"
448
457
)
449
458
0 commit comments