src/HOL/SPARK/Tools/spark_commands.ML
changeset 56208 06cc31dff138
parent 55789 8d4d339177dc
child 56334 6b3739fee456
equal deleted inserted replaced
56207:52d5067ca06a 56208:06cc31dff138
    10 fun spark_open header (prfx, files) thy =
    10 fun spark_open header (prfx, files) thy =
    11   let
    11   let
    12     val ([{src_path, lines = vc_lines, pos = vc_pos, ...}: Token.file,
    12     val ([{src_path, lines = vc_lines, pos = vc_pos, ...}: Token.file,
    13       {lines = fdl_lines, pos = fdl_pos, ...},
    13       {lines = fdl_lines, pos = fdl_pos, ...},
    14       {lines = rls_lines, pos = rls_pos, ...}], thy') = files thy;
    14       {lines = rls_lines, pos = rls_pos, ...}], thy') = files thy;
    15     val base = fst (Path.split_ext (File.full_path (Thy_Load.master_directory thy') src_path));
    15     val base = fst (Path.split_ext (File.full_path (Resources.master_directory thy') src_path));
    16   in
    16   in
    17     SPARK_VCs.set_vcs
    17     SPARK_VCs.set_vcs
    18       (snd (Fdl_Parser.parse_declarations fdl_pos (cat_lines fdl_lines)))
    18       (snd (Fdl_Parser.parse_declarations fdl_pos (cat_lines fdl_lines)))
    19       (Fdl_Parser.parse_rules rls_pos (cat_lines rls_lines))
    19       (Fdl_Parser.parse_rules rls_pos (cat_lines rls_lines))
    20       (snd (Fdl_Parser.parse_vcs header vc_pos (cat_lines vc_lines)))
    20       (snd (Fdl_Parser.parse_vcs header vc_pos (cat_lines vc_lines)))
    22   end;
    22   end;
    23 
    23 
    24 (* FIXME *)
    24 (* FIXME *)
    25 fun spark_open_old (vc_name, prfx) thy =
    25 fun spark_open_old (vc_name, prfx) thy =
    26   let
    26   let
    27     val ((vc_path, vc_id), vc_text) = Thy_Load.load_file thy (Path.explode vc_name);
    27     val ((vc_path, vc_id), vc_text) = Resources.load_file thy (Path.explode vc_name);
    28     val (base, header) =
    28     val (base, header) =
    29       (case Path.split_ext vc_path of
    29       (case Path.split_ext vc_path of
    30         (base, "vcg") => (base, Fdl_Lexer.vcg_header >> K ())
    30         (base, "vcg") => (base, Fdl_Lexer.vcg_header >> K ())
    31       | (base, "siv") => (base, Fdl_Lexer.siv_header >> K ())
    31       | (base, "siv") => (base, Fdl_Lexer.siv_header >> K ())
    32       | _ => error "File name must end with .vcg or .siv");
    32       | _ => error "File name must end with .vcg or .siv");
   115     (Parse.name -- Parse.parname >> (Toplevel.theory o spark_open_old));
   115     (Parse.name -- Parse.parname >> (Toplevel.theory o spark_open_old));
   116 
   116 
   117 val _ =
   117 val _ =
   118   Outer_Syntax.command @{command_spec "spark_open_vcg"}
   118   Outer_Syntax.command @{command_spec "spark_open_vcg"}
   119     "open a new SPARK environment and load a SPARK-generated .vcg file"
   119     "open a new SPARK environment and load a SPARK-generated .vcg file"
   120     (Parse.parname -- Thy_Load.provide_parse_files "spark_open_vcg"
   120     (Parse.parname -- Resources.provide_parse_files "spark_open_vcg"
   121       >> (Toplevel.theory o spark_open Fdl_Lexer.vcg_header));
   121       >> (Toplevel.theory o spark_open Fdl_Lexer.vcg_header));
   122 
   122 
   123 val _ =
   123 val _ =
   124   Outer_Syntax.command @{command_spec "spark_open_siv"}
   124   Outer_Syntax.command @{command_spec "spark_open_siv"}
   125     "open a new SPARK environment and load a SPARK-generated .siv file"
   125     "open a new SPARK environment and load a SPARK-generated .siv file"
   126     (Parse.parname -- Thy_Load.provide_parse_files "spark_open_siv"
   126     (Parse.parname -- Resources.provide_parse_files "spark_open_siv"
   127       >> (Toplevel.theory o spark_open Fdl_Lexer.siv_header));
   127       >> (Toplevel.theory o spark_open Fdl_Lexer.siv_header));
   128 
   128 
   129 val pfun_type = Scan.option
   129 val pfun_type = Scan.option
   130   (Args.parens (Parse.list1 Parse.name) --| Args.colon -- Parse.name);
   130   (Args.parens (Parse.list1 Parse.name) --| Args.colon -- Parse.name);
   131 
   131