diff --git a/lib/02_parsing/Ast.ml b/lib/02_parsing/Ast.ml index 84f2ceb..1d35955 100644 --- a/lib/02_parsing/Ast.ml +++ b/lib/02_parsing/Ast.ml @@ -28,7 +28,7 @@ and tag = { tag_desc : tag_desc; } -and tag_typ = +and tag_kind = | Tag_String | Tag_Int | Tag_Float @@ -44,7 +44,7 @@ and tag_typ = | Tag_Custom of string and tag_desc = { - tag : tag_typ; + tag : tag_kind; key : string; required : bool; attributes : expression StringMap.t; @@ -129,10 +129,10 @@ and statement_desc = and declaration = { declaration_loc : Pinc_Diagnostics.Location.t; - declaration_type : declaration_type; + declaration_kind : declaration_kind; } -and declaration_type = +and declaration_kind = | Declaration_Component of declaration_desc | Declaration_Library of declaration_desc | Declaration_Page of declaration_desc diff --git a/lib/02_parsing/Parser.ml b/lib/02_parsing/Parser.ml index d31542d..8dcb7a6 100644 --- a/lib/02_parsing/Parser.ml +++ b/lib/02_parsing/Parser.ml @@ -785,7 +785,7 @@ module Rules = struct and parse_declaration t = let declaration_start = t.token.location in - let* identifier, declaration_type = + let* identifier, declaration_kind = match t.token.typ with | ( Token.KEYWORD_PAGE | Token.KEYWORD_COMPONENT @@ -833,7 +833,7 @@ module Rules = struct in let declaration_end = t.token.location in let declaration_loc = Location.merge ~s:declaration_start ~e:declaration_end () in - (identifier, Parsetree.{ declaration_loc; declaration_type }) |> Option.some + (identifier, Parsetree.{ declaration_loc; declaration_kind }) |> Option.some ;; end diff --git a/lib/02_parsing/Parsetree.ml b/lib/02_parsing/Parsetree.ml index f6e124d..b55607c 100644 --- a/lib/02_parsing/Parsetree.ml +++ b/lib/02_parsing/Parsetree.ml @@ -26,7 +26,7 @@ and tag = { tag_desc : tag_desc; } -and tag_typ = +and tag_kind = | P_Tag_String | P_Tag_Int | P_Tag_Float @@ -42,7 +42,7 @@ and tag_typ = | P_Tag_Custom of string and tag_desc = { - tag : tag_typ; + tag : tag_kind; attributes : expression StringMap.t; transformer : expression option; } @@ -122,10 +122,10 @@ and statement_desc = and declaration = { declaration_loc : Pinc_Diagnostics.Location.t; - declaration_type : declaration_type; + declaration_kind : declaration_kind; } -and declaration_type = +and declaration_kind = | P_Declaration_Component of declaration_desc | P_Declaration_Library of declaration_desc | P_Declaration_Page of declaration_desc diff --git a/lib/02_parsing/Transformer.ml b/lib/02_parsing/Transformer.ml index 0961b31..189bef6 100644 --- a/lib/02_parsing/Transformer.ml +++ b/lib/02_parsing/Transformer.ml @@ -579,14 +579,14 @@ and transform_store_declaration env (declaration : Parsetree.declaration_desc) = (env, Declaration_Store { declaration_attributes; declaration_body }) and transform_declaration env (declaration : Parsetree.declaration) = - let env, declaration_type = - match declaration.declaration_type with + let env, declaration_kind = + match declaration.declaration_kind with | P_Declaration_Component desc -> transform_component_declaration env desc | P_Declaration_Library desc -> transform_library_declaration env desc | P_Declaration_Page desc -> transform_page_declaration env desc | P_Declaration_Store desc -> transform_store_declaration env desc in - (env, { declaration_loc = declaration.declaration_loc; declaration_type }) + (env, { declaration_loc = declaration.declaration_loc; declaration_kind }) and transform_declarations env declarations = StringMap.fold_map ~init:env ~f:transform_declaration declarations diff --git a/lib/pinc_backend/DeclarationEvaluator.ml b/lib/pinc_backend/DeclarationEvaluator.ml index c0754e9..dde6ab2 100644 --- a/lib/pinc_backend/DeclarationEvaluator.ml +++ b/lib/pinc_backend/DeclarationEvaluator.ml @@ -2,7 +2,7 @@ let eval ~eval_expression ~state declaration = state.Types.Type_State.declarations |> StringMap.find_opt declaration |> function | Some { - Pinc_Parser.Ast.declaration_type = + Pinc_Parser.Ast.declaration_kind = ( Declaration_Component { declaration_body; _ } | Declaration_Library { declaration_body; _ } | Declaration_Page { declaration_body; _ } diff --git a/lib/pinc_backend/Helpers.ml b/lib/pinc_backend/Helpers.ml index e39784b..7ed4165 100644 --- a/lib/pinc_backend/Helpers.ml +++ b/lib/pinc_backend/Helpers.ml @@ -153,7 +153,7 @@ module Expect = struct let declarations = StringMap.fold (fun id decl acc -> - match (typ, decl.Pinc_Parser.Ast.declaration_type) with + match (typ, decl.Pinc_Parser.Ast.declaration_kind) with | (`All | `Component), Declaration_Component _ -> id :: acc | (`All | `Library), Declaration_Library _ -> id :: acc | (`All | `Page), Declaration_Page _ -> id :: acc diff --git a/lib/pinc_backend/Interpreter.ml b/lib/pinc_backend/Interpreter.ml index 0c86cc4..35e2169 100644 --- a/lib/pinc_backend/Interpreter.ml +++ b/lib/pinc_backend/Interpreter.ml @@ -18,12 +18,12 @@ let rec get_uppercase_identifier_typ ~state ident = let declaration = state.declarations |> StringMap.find_opt ident in match declaration with | None -> (state, None) - | Some { declaration_type = Ast.Declaration_Component _; _ } -> + | Some { declaration_kind = Ast.Declaration_Component _; _ } -> (state, Some Definition_Component) - | Some { declaration_type = Ast.Declaration_Page _; _ } -> (state, Some Definition_Page) + | Some { declaration_kind = Ast.Declaration_Page _; _ } -> (state, Some Definition_Page) | Some { - declaration_type = + declaration_kind = Ast.Declaration_Store { declaration_attributes; declaration_body }; _; } -> ( @@ -57,7 +57,7 @@ let rec get_uppercase_identifier_typ ~state ident = let store = Type_Store.make ~singleton ~body:declaration_body in add_store ~store ~ident; (state, Some (Definition_Store store))) - | Some { declaration_type = Ast.Declaration_Library { declaration_body; _ }; _ } -> ( + | Some { declaration_kind = Ast.Declaration_Library { declaration_body; _ }; _ } -> ( match Hashtbl.find_opt libraries ident with | Some library -> (state, Some (Definition_Library library)) | None -> @@ -1369,19 +1369,19 @@ let eval_meta sources = |> StringMap.map (function | { declaration_loc; - declaration_type = Declaration_Component { declaration_attributes; _ }; + declaration_kind = Declaration_Component { declaration_attributes; _ }; } -> `Component (declaration_loc, eval declaration_attributes) | { declaration_loc; - declaration_type = Declaration_Library { declaration_attributes; _ }; + declaration_kind = Declaration_Library { declaration_attributes; _ }; } -> `Library (declaration_loc, eval declaration_attributes) | { declaration_loc; - declaration_type = Declaration_Page { declaration_attributes; _ }; + declaration_kind = Declaration_Page { declaration_attributes; _ }; } -> `Page (declaration_loc, eval declaration_attributes) | { declaration_loc; - declaration_type = Declaration_Store { declaration_attributes; _ }; + declaration_kind = Declaration_Store { declaration_attributes; _ }; } -> `Store (declaration_loc, eval declaration_attributes)) ;; @@ -1393,7 +1393,7 @@ let eval_declarations Hashtbl.reset Tag.Tag_Portal.portals; (match declarations |> StringMap.find_opt root with - | Some { Ast.declaration_type = Declaration_Library _ | Declaration_Store _; _ } -> + | Some { Ast.declaration_kind = Declaration_Library _ | Declaration_Store _; _ } -> raise_notrace (Invalid_argument (root ^ " can not be evaluated")) | _ -> ());