11open Compiler.Types
22
3+ module Error = struct
4+ module Set = BatSet. String
5+
6+ let supported_directives =
7+ Set. of_list [ " persisted" ; " ephemeral" ; " constraint" ; " stored" ]
8+
9+ let treat_error_cases
10+ ((qualifier , name ) :
11+ string Location. with_location * string Location. with_location )
12+ (arity : int ) : unit =
13+ if arity <> 0 then (
14+ Logger. error qualifier.loc " Sakura directives should be qualified atoms" ;
15+ exit 1 )
16+ else if qualifier.content = " sakura" then (
17+ if Set. mem name.content supported_directives then ()
18+ else Logger. error name.loc @@ " Undefined Sakura directive:" ^ name.content;
19+ exit 1 )
20+ else (
21+ Logger. error qualifier.loc
22+ " Sakura directives should be qualified with 'sakura'" ;
23+ exit 1 )
24+ end
25+
326let compile (directive_loc : Location.location )
427 ({ arity; _ } as func : Ast.Expr.func ) (body : Ast.Clause.t list list )
528 (step : Ast.Clause.t list * t -> t )
@@ -17,22 +40,29 @@ let compile (directive_loc : Location.location)
1740 | "project" , 0 , _ ->
1841 Logger. error directive_loc " Sakura does not support project directive" ;
1942 exit 1
20- | "persisted" , _ , _ ->
21- Logger. error directive_loc
22- " TODO: persisted directive is not yet implemented" ;
23- exit 1
24- | "ephemeral" , _ , _ ->
25- Logger. error directive_loc
26- " TODO: ephemeral directive is not yet implemented" ;
27- exit 1
28- | "constraint" , _ , _ ->
29- Logger. error directive_loc
30- " TODO: constraint directive is not yet implemented" ;
31- exit 1
32- | "stored" , _ , _ ->
33- Logger. unreachable directive_loc
34- " Stored procedures are not supported in Sakura yet" ;
35- exit 1
36- | _ ->
37- Logger. simply_unreachable " Unknown directive for Sakura" ;
38- exit 1
43+ | _ -> (
44+ let open Location in
45+ let ((qualifier, name) as func_label ) =
46+ Ast.Expr. extract_qualified_func_label func
47+ in
48+ match (qualifier.content, name.content, arity) with
49+ | "sakura" , "persisted" , 0 ->
50+ Logger. error directive_loc
51+ " TODO: persisted directive is not yet implemented" ;
52+ exit 1
53+ | "sakura" , "ephemeral" , 0 ->
54+ Logger. error directive_loc
55+ " TODO: ephemeral directive is not yet implemented" ;
56+ exit 1
57+ | "sakura" , "constraint" , 0 ->
58+ Logger. error directive_loc
59+ " TODO: constraint directive is not yet implemented" ;
60+ exit 1
61+ | "sakura" , "stored" , 0 ->
62+ Logger. unreachable directive_loc
63+ " Stored procedures are not supported in Sakura yet" ;
64+ exit 1
65+ | _ ->
66+ Error. treat_error_cases func_label arity;
67+ Logger. simply_unreachable " Unknown directive for Sakura" ;
68+ exit 1 )
0 commit comments