WIP: fix parser error
This commit is contained in:
parent
27f583266e
commit
092360de93
@ -203,7 +203,7 @@ field_decl:
|
|||||||
and value = {field_name=$1; colon=$2; field_type=$3}
|
and value = {field_name=$1; colon=$2; field_type=$3}
|
||||||
in {region; value} }
|
in {region; value} }
|
||||||
|
|
||||||
(* Top-level non-recursive definitions *)
|
(* Top-level non-eecursive definitions *)
|
||||||
|
|
||||||
let_declaration:
|
let_declaration:
|
||||||
"let" ioption("rec") let_binding seq(Attr) {
|
"let" ioption("rec") let_binding seq(Attr) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ module Errors =
|
|||||||
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc)] *)
|
fun () -> Format.asprintf "%a" Location.pp_lift @@ loc)] *)
|
||||||
|
|
||||||
let generic message =
|
let generic message =
|
||||||
let title () = ""
|
let title () = "scofzpfj%!"
|
||||||
and message () = message.Region.value
|
and message () = message.Region.value
|
||||||
in Trace.error ~data:[] title message
|
in Trace.error ~data:[] title message
|
||||||
end
|
end
|
||||||
@ -182,10 +182,14 @@ let parse_expression (s: string) =
|
|||||||
let ext = PreIO.ext
|
let ext = PreIO.ext
|
||||||
let options = PreIO.pre_options ~input:None ~expr:true
|
let options = PreIO.pre_options ~input:None ~expr:true
|
||||||
end in
|
end in
|
||||||
|
Format.printf "coucou : %s\n%!" s;
|
||||||
let module Unit = PreUnit (IO) in
|
let module Unit = PreUnit (IO) in
|
||||||
match Lexer.(open_token_stream @@ String s) with
|
match Lexer.(open_token_stream @@ String s) with
|
||||||
Ok instance ->
|
Ok instance ->
|
||||||
let thunk () = Unit.apply instance Unit.parse_expr
|
let thunk () = Unit.apply instance Unit.parse_expr
|
||||||
in parse (module IO) thunk
|
in
|
||||||
|
Format.printf "ok\n%!";
|
||||||
|
parse (module IO) thunk
|
||||||
| Stdlib.Error (Lexer.File_opening msg) ->
|
| Stdlib.Error (Lexer.File_opening msg) ->
|
||||||
|
Format.printf "fail\n%!";
|
||||||
Trace.fail @@ Errors.generic @@ Region.wrap_ghost msg
|
Trace.fail @@ Errors.generic @@ Region.wrap_ghost msg
|
||||||
|
@ -237,21 +237,10 @@ field_decl:
|
|||||||
|
|
||||||
|
|
||||||
fun_expr:
|
fun_expr:
|
||||||
| "function" parameters ":" type_expr "is" expr {
|
| ioption ("recursive") "function" parameters ":" type_expr "is" expr {
|
||||||
let stop = expr_to_region $6 in
|
|
||||||
let region = cover $1 stop
|
|
||||||
and value = {kwd_recursive= None;
|
|
||||||
kwd_function = $1;
|
|
||||||
param = $2;
|
|
||||||
colon = $3;
|
|
||||||
ret_type = $4;
|
|
||||||
kwd_is = $5;
|
|
||||||
return = $6}
|
|
||||||
in {region; value} }
|
|
||||||
| "recursive" "function" parameters ":" type_expr "is" expr {
|
|
||||||
let stop = expr_to_region $7 in
|
let stop = expr_to_region $7 in
|
||||||
let region = cover $2 stop
|
let region = cover $2 stop
|
||||||
and value = {kwd_recursive= Some($1);
|
and value = {kwd_recursive= $1;
|
||||||
kwd_function = $2;
|
kwd_function = $2;
|
||||||
param = $3;
|
param = $3;
|
||||||
colon = $4;
|
colon = $4;
|
||||||
@ -263,7 +252,7 @@ fun_expr:
|
|||||||
(* Function declarations *)
|
(* Function declarations *)
|
||||||
|
|
||||||
open_fun_decl:
|
open_fun_decl:
|
||||||
"recursive"? "function" fun_name parameters ":" type_expr "is"
|
ioption ("recursive") "function" fun_name parameters ":" type_expr "is"
|
||||||
block "with" expr {
|
block "with" expr {
|
||||||
Scoping.check_reserved_name $3;
|
Scoping.check_reserved_name $3;
|
||||||
let stop = expr_to_region $10 in
|
let stop = expr_to_region $10 in
|
||||||
@ -281,7 +270,7 @@ open_fun_decl:
|
|||||||
attributes = None}
|
attributes = None}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
| "recursive"? "function" fun_name parameters ":" type_expr "is" expr {
|
| ioption ("recursive") "function" fun_name parameters ":" type_expr "is" expr {
|
||||||
Scoping.check_reserved_name $3;
|
Scoping.check_reserved_name $3;
|
||||||
let stop = expr_to_region $8 in
|
let stop = expr_to_region $8 in
|
||||||
let region = cover $2 stop
|
let region = cover $2 stop
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ let reasonligo_sdata = {
|
|||||||
parser = Parser.Reasonligo.parse_expression }
|
parser = Parser.Reasonligo.parse_expression }
|
||||||
|
|
||||||
let get_exp_as_string filename =
|
let get_exp_as_string filename =
|
||||||
|
Format.printf "Get file\n%!";
|
||||||
let lines = ref [] in
|
let lines = ref [] in
|
||||||
let chan = open_in filename in
|
let chan = open_in filename in
|
||||||
try
|
try
|
||||||
@ -21,11 +22,17 @@ let get_exp_as_string filename =
|
|||||||
done; !lines
|
done; !lines
|
||||||
with End_of_file ->
|
with End_of_file ->
|
||||||
close_in chan;
|
close_in chan;
|
||||||
|
Format.printf "End file\n%!";
|
||||||
List.rev !lines ;;
|
List.rev !lines ;;
|
||||||
|
|
||||||
let assert_syntax_error sdata () =
|
let assert_syntax_error sdata () =
|
||||||
|
Format.printf "ASsert\n%!";
|
||||||
|
let n = ref 0 in
|
||||||
let%bind _l = bind_iter_list
|
let%bind _l = bind_iter_list
|
||||||
(fun entry -> Assert.assert_fail @@ sdata.parser entry)
|
(fun entry ->
|
||||||
|
n := !n+1;
|
||||||
|
Format.printf "Line %d : %s\n%!" !n entry;
|
||||||
|
Assert.assert_fail @@ sdata.parser entry)
|
||||||
(get_exp_as_string sdata.erroneous_source_file) in
|
(get_exp_as_string sdata.erroneous_source_file) in
|
||||||
ok ()
|
ok ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user