tests pasS

This commit is contained in:
Galfour 2019-04-07 13:59:36 +00:00
parent e9f90858a2
commit 8f518a508f

View File

@ -1,31 +1,37 @@
open Trace open Trace
let parse_file (source: string) : Ast.entry_point result = let parse_file (source: string) : Ast.entry_point result =
let pp_input = (* let pp_input =
let prefix = Filename.(source |> basename |> remove_extension) * let prefix = Filename.(source |> basename |> remove_extension)
and suffix = ".pp.ligo" * and suffix = ".pp.ligo"
in prefix ^ suffix in * in prefix ^ suffix in
*
let cpp_cmd = Printf.sprintf "cpp -traditional-cpp %s -o %s" * let cpp_cmd = Printf.sprintf "cpp -traditional-cpp %s -o %s"
source pp_input in * source pp_input in
let%bind () = sys_command cpp_cmd in * let%bind () = sys_command cpp_cmd in
*
* let%bind channel =
* generic_try (simple_error "error opening file") @@
* (fun () -> open_in pp_input) in *)
let%bind channel = let%bind channel =
generic_try (simple_error "error opening file") @@ generic_try (simple_error "error opening file") @@
(fun () -> open_in pp_input) in (fun () -> open_in source) in
let lexbuf = Lexing.from_channel channel in let lexbuf = Lexing.from_channel channel in
let module Lexer = Lex.Lexer in let module Lexer = Lex.Lexer in
specific_try (function specific_try (fun e ->
| Parser.Error -> ( let error = fun s ->
let start = Lexing.lexeme_start_p lexbuf in let start = Lexing.lexeme_start_p lexbuf in
let end_ = Lexing.lexeme_end_p lexbuf in let end_ = Lexing.lexeme_end_p lexbuf in
let str = Format.sprintf let str = Format.sprintf
"Parse error at \"%s\" from (%d, %d) to (%d, %d)\n" "at \"%s\" from (%d, %d) to (%d, %d)\n"
(Lexing.lexeme lexbuf) (Lexing.lexeme lexbuf)
start.pos_lnum (start.pos_cnum - start.pos_bol) start.pos_lnum (start.pos_cnum - start.pos_bol)
end_.pos_lnum (end_.pos_cnum - end_.pos_bol) in end_.pos_lnum (end_.pos_cnum - end_.pos_bol) in
simple_error str error s str in
) match e with
| Parser.Error -> error "Parse"
| Lexer.Error s -> error ("Lexer " ^ s)
| Lexer.Unexpected_character _ -> error "Unexpected char"
| _ -> simple_error "unrecognized parse_ error" | _ -> simple_error "unrecognized parse_ error"
) @@ (fun () -> ) @@ (fun () ->
let raw = Parser.entry_point Lexer.token lexbuf in let raw = Parser.entry_point Lexer.token lexbuf in