1{- 2 SkateSchema: Represents a parsed Skate Schema 3 4 Part of Skate: a Schema specification languge 5 6 Copyright (c) 2017, ETH Zurich. 7 All rights reserved. 8 9 This file is distributed under the terms in the attached LICENSE file. 10 If you do not find this file, copies can be found by writing to: 11 ETH Zurich D-INFK, Universit\"atstr. 6, CH-8092 Zurich. Attn: Systems Group. 12-} 13 14module SkateSchema where 15 16import SkateParser 17 18import System.IO 19import System.IO.Error 20import Text.Printf 21 22import qualified SkateTypeTable as TT 23import qualified SkateDeclarationTable as DT 24 25data SchemaRecord = SchemaRecord { 26 name :: String, 27 desc :: String, 28 schema:: Schema, 29 30 facts :: [Declaration], 31 flags :: [Declaration], 32 constants :: [Declaration], 33 enumerations :: [Declaration], 34 namespaces :: [Declaration], 35 36 types :: [TT.TTEntry], 37 allTypes :: [TT.TTEntry], 38 imports :: [ String ] 39} 40 41 42skateSchemaTransform :: SchemaRecord -> IO(SchemaRecord) 43skateSchemaTransform sr = do { 44 return (sr) 45 } 46 47 48 49make_schema_record :: Schema -> [Schema] -> IO SchemaRecord 50make_schema_record s@(Schema n d decls imps sp) dfl = 51 do { 52 printf "Creating SchemRecord.\n"; 53 ttbl <- TT.make_table s; 54 DT.DTRec ns fa fl co en <- DT.make_table s ttbl; 55 --dt <- DT.make_table s ttbl; 56 --facts <- DT.make_facts_table s ttbl 57 --namespaces <-DT.make_namespaces_table s ttbl 58 --flags <-DT.make_flags_table s ttbl 59 --constants <-DT.make_constants_table s ttbl 60 --enums <-DT.make_enumerations_table s ttbl 61 62 --ftbl <- DT.make_table ttbl decls n; 63 --qtbl <- DT.make_table ttbl decls n; 64 return SchemaRecord { 65 name = n, 66 desc = d, 67 schema = s, 68 types = ttbl, 69 allTypes = ttbl, -- ++ ( concat $ map TT.make_rtypetable dfl ), 70 facts = fa, 71 flags = fl, 72 constants = co, 73 enumerations = en, 74 namespaces = ns, 75 imports = imps 76 } 77 } 78 79 80 81 82skateSchemaGetAst :: SchemaRecord -> Schema 83skateSchemaGetAst sr@(SchemaRecord _ _ s _ _ _ _ _ _ _ _) = s 84 85skateSchemaGetFacts :: SchemaRecord -> [Declaration] 86skateSchemaGetFacts sr = facts sr 87