Commit 5eb551a1 authored by POGODALLA Sylvain's avatar POGODALLA Sylvain
Browse files

New script commands added

parent 4c11aa78
......@@ -110,6 +110,10 @@ struct
let start_term () = No_type_or_term_in_def
let start_sig_entry () = Sig (Sig_dec_id (Sig_dec_equal (No_entry)))
let start_lex_entry () = Lex(Lex_def No_lex_entry)
let build_expectation lst =
let rec build_expectation_rec lst k =
match lst with
......
......@@ -48,10 +48,17 @@ sig
initial state of the automaton *)
val start_data : unit -> data
(** [start_term ()] returns an empty data corresponding to the
(** [start_term ()] returns an empty term corresponding to the
initial state of the automaton *)
val start_term : unit -> term
(** [start_sig_entry ()] returns a data corresponding to the state
of the automaton for entering a sig entry *)
val start_sig_entry : unit -> data
(** [start_lex_entry ()] returns a data corresponding to the
state of the automaton for entering a lex entry *)
val start_lex_entry : unit -> data
(** [data_transition d v] returns the state of the automaton reached
from [d] with valuation [v] *)
val data_transition : data -> valuation -> data
......
......@@ -101,7 +101,7 @@ sig
val unselect : t -> t
val focus : t -> entry
val focus : t -> entry option
end
......@@ -174,10 +174,7 @@ struct
let unselect e = {e with focus=None}
let focus {focus=f} =
match f with
| None -> raise (Entry_not_found "focused")
| Some e -> e
let focus {focus=f} = f
......
......@@ -148,7 +148,7 @@ sig
val unselect : t -> t
val focus : t -> entry
val focus : t -> entry option
end
......
......@@ -38,6 +38,12 @@
let set_to_term () =
data := Term (Entry.start_term ())
let set_to_sig_entry () =
data := Data (Entry.start_sig_entry ())
let set_to_lex_entry () =
data := Data (Entry.start_lex_entry ())
let update_data v (p1,p2) =
try
......
......@@ -144,7 +144,9 @@
<(string*Abstract_syntax.location)> IDENT
<(string*Abstract_syntax.location)> SYMBOL
%start <E.t> data
%start <E.t> data
%start <E.Signature1.t -> E.Signature1.t> sig_entry
%start <E.Lexicon.t -> E.Lexicon.t> lex_entry
%start <(E.Signature1.term*E.Signature1.stype)> term_alone
%relation atom<app<sym_app<binder atom_type<arrow_type
......@@ -389,11 +391,6 @@ sig_entries :
| lex_entry[e] END_OF_DEC {fun lex -> e lex}
| lex_entry[e] SEMICOLON lex_entries[es] {fun lex -> es (e lex)}
/* lex_entries :
| lex_entry[e] optional_semi_colon_before_end {fun lex -> e lex}
| lex_entry[e] SEMICOLON lex_entries[es] {fun lex -> es (e lex)}
*/
lex_entry :
| comma_ids_or_sym[ids] COLON_EQUAL ...{
......@@ -509,6 +506,52 @@ sig_entries :
(Error.error_msg er "stdin") in
None
| End_of_file -> None
let parse_sig_entry ?(offset="") t sg =
let lexbuf = Lexing.from_string t in
try
let () = Lexer.set_to_sig_entry () in
try Some ((fst (List.hd(sig_entry ~global_data:false ~local_data:(Some (Signature sg)) Lexer.lexer lexbuf))) sg) with
| Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin")
with
| Error.Error er ->
let s,e = Error.get_loc_error er in
let s',e' = s.Lexing.pos_cnum - s.Lexing.pos_bol,e.Lexing.pos_cnum - e.Lexing.pos_bol in
let () = Printf.fprintf
stderr
"%s\n%s%s%s\nError: %s\n%!"
t
offset
(String.make s' ' ')
(String.make (e'-s') '^')
(Error.error_msg er "stdin") in
None
| End_of_file -> None
let parse_lex_entry ?(offset="") t lex =
let lexbuf = Lexing.from_string t in
try
let () = Lexer.set_to_lex_entry () in
try Some ((fst (List.hd(lex_entry ~global_data:false ~local_data:(Some (Abs_and_obj (E.Lexicon.get_sig lex))) Lexer.lexer lexbuf))) lex) with
| Dyp.Syntax_error -> raise (Error.dyp_error lexbuf "stdin")
with
| Error.Error er ->
let s,e = Error.get_loc_error er in
let s',e' = s.Lexing.pos_cnum - s.Lexing.pos_bol,e.Lexing.pos_cnum - e.Lexing.pos_bol in
let () = Printf.fprintf
stderr
"%s\n%s%s%s\nError: %s\n%!"
t
offset
(String.make s' ' ')
(String.make (e'-s') '^')
(Error.error_msg er "stdin") in
None
| End_of_file -> None
......@@ -539,6 +582,10 @@ end}
and [None] otherwise *)
val parse_term : ?offset:string -> ?output:bool -> string -> E.Signature1.t -> (E.Signature1.term*E.Signature1.stype) option
val parse_sig_entry : ?offset:string -> string -> E.Signature1.t -> E.Signature1.t option
val parse_lex_entry : ?offset:string -> string -> E.Lexicon.t -> E.Lexicon.t option
type local_data =
| Signature of E.Signature1.t
......
......@@ -16,12 +16,13 @@ sig
| Dont_trace
| Print
| Analyse
| Add
| Compose
| Dont_wait
| Wait
| Help of action option
| Create
| Save
type file_type = | Data | Script of (string -> env -> env)
......@@ -41,6 +42,8 @@ sig
val analyse : ?names:(string * (Lexing.position * Lexing.position)) list -> env -> ?offset:string -> string -> (Lexing.position * Lexing.position) -> unit
val add : ?names:(string * (Lexing.position * Lexing.position)) list -> env -> ?offset:string -> string -> (Lexing.position * Lexing.position) -> env
val compose :
string * (Lexing.position * Lexing.position) ->
string * (Lexing.position * Lexing.position) ->
......@@ -55,6 +58,14 @@ sig
val help : action -> unit
val exit : unit -> unit
val create_sig : (string * (Lexing.position * Lexing.position)) -> env -> env
val create_lex : abs:(string * (Lexing.position * Lexing.position)) -> obj:(string * (Lexing.position * Lexing.position)) -> (string * (Lexing.position * Lexing.position)) -> env -> env
val save : ?names:(string * (Lexing.position * Lexing.position)) list -> string -> env -> (Lexing.position * Lexing.position) -> unit
end
......@@ -62,6 +73,7 @@ module Make (E:Environment_sig) =
struct
type env=E.t
type entry=E.entry
exception Not_yet_implemented of string
......@@ -117,9 +129,10 @@ struct
let print ?name e l =
try
let entry =
match name with
| None -> E.focus e
| Some n -> E.get n e
match name,E.focus e with
| None,None -> raise (Scripting_errors.Error (Scripting_errors.No_focus,l))
| None,Some en -> en
| Some n,_ -> E.get n e
in
match entry with
| E.Signature sg -> Format.printf "%s\n%!" (E.Signature1.to_string sg)
......@@ -139,9 +152,10 @@ struct
let additional_offset = "\t" in
let actual_offset = Printf.sprintf "%s%s" (match offset with | None -> "" | Some s -> s) additional_offset in
let entries =
match names with
| None -> [E.focus e]
| Some ns -> List.map (fun (n,l) ->
match names,E.focus e with
| None,None -> raise (Scripting_errors.Error (Scripting_errors.No_focus,l))
| None,Some en -> [en]
| Some ns,_ -> List.map (fun (n,l) ->
try
E.get n e
with
......@@ -179,6 +193,54 @@ struct
| E.Signature_not_found n
| E.Lexicon_not_found n
| E.Entry_not_found n -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment n,l))
let entry_name = function
| E.Signature sg -> fst (E.Signature1.name sg)
| E.Lexicon lex -> fst (E.Lexicon.name lex)
let add ?names e ?offset data l =
try
let additional_offset = "" in
let actual_offset = Printf.sprintf "%s%s" (match offset with | None -> "" | Some s -> s) additional_offset in
let entries,update_focus,foc_name =
match names,E.focus e with
| None,None -> raise (Scripting_errors.Error (Scripting_errors.No_focus,l))
| None,Some en -> [en],true,entry_name en
| Some ns,None ->
(List.map (fun (n,l) ->
try
E.get n e
with
| E.Entry_not_found s -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment s,l))) ns),false,""
| Some ns,Some foc ->
let foc_name=entry_name foc in
List.fold_left
(fun (acc,b,name) (n,l) ->
try
(E.get n e)::acc,b or n=foc_name,name
with
| E.Entry_not_found s -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment s,l)))
([],false,foc_name)
ns in
let new_env =
List.fold_left
(fun acc entry -> match entry with
| E.Signature sg ->
(match Data_parser.parse_sig_entry ~offset:actual_offset data sg with
| None -> acc
| Some new_sg -> E.insert ~override:true (E.Signature new_sg) acc)
| E.Lexicon lex ->
(match Data_parser.parse_lex_entry ~offset:actual_offset data lex with
| None -> acc
| Some new_lex -> E.insert ~override:true (E.Lexicon new_lex) acc))
e
entries in
if update_focus then E.select foc_name new_env else new_env
with
| E.Signature_not_found n
| E.Lexicon_not_found n
| E.Entry_not_found n -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment n,l))
......@@ -192,7 +254,44 @@ struct
let lex2 = get_lex n2 in
let () = Format.printf "%s = %s o %s\n%!" (fst n3) (fst n1) (fst n2) in
E.insert ~override:true (E.Lexicon (E.Lexicon.compose lex1 lex2 n3)) e
let create_sig (n,_) e =
E.insert ~override:true (E.Signature (E.Signature1.empty (n,(Lexing.dummy_pos,Lexing.dummy_pos)))) e
let get_sig (n,l) e =
try
E.get_signature n e
with
| E.Signature_not_found s -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment s,l))
let create_lex ~abs ~obj (n,_) e =
let abs_sg=get_sig abs e in
let obj_sg=get_sig obj e in
E.insert ~override:true (E.Lexicon (E.Lexicon.empty (n,(Lexing.dummy_pos,Lexing.dummy_pos)) abs_sg obj_sg)) e
let save ?names filename e l =
let entries =
match names,E.focus e with
| None,None -> raise (Scripting_errors.Error (Scripting_errors.No_focus,l))
| None,Some en -> [en]
| Some ns,_ -> List.map (fun (n,l) ->
try
E.get n e
with
| E.Entry_not_found s -> raise (Scripting_errors.Error (Scripting_errors.Not_in_environment s,l))) ns in
(* Protger les accs avec de bons messages d'erreur *)
let outch = open_out filename in
let () = List.iter
(fun entry ->
match entry with
| E.Signature sg -> Printf.fprintf outch "%s\n\n%!" (E.Signature1.to_string sg)
| E.Lexicon lex -> Printf.fprintf outch "%s\n\n%!" (E.Lexicon.to_string lex))
entries in
close_out outch
let wait () = interactive := true
let dont_wait () = interactive := false
......@@ -208,10 +307,18 @@ struct
| Dont_trace
| Print
| Analyse
| Add
| Compose
| Dont_wait
| Wait
| Help of action option
| Create
| Save
let actions = [Load;List;Select;Unselect;Trace;Dont_trace;Print;Analyse;Add;Compose;Dont_wait;Wait;Help None;Create;Save]
let rec action_to_string = function
| Load -> "load"
......@@ -222,40 +329,43 @@ struct
| Dont_trace -> "don't trace"
| Print -> "print"
| Analyse -> "analyse"
| Add -> "add"
| Compose -> "compose"
| Dont_wait -> "don't wait"
| Wait -> "wait"
| Help None -> "help"
| Help (Some (Help a)) -> action_to_string (Help a)
| Help (Some a) -> Format.sprintf "%s help" (action_to_string a)
| Save -> "save"
| Create -> "create"
let help_messages = [
Load,Format.sprintf "\t%s d|s file;\n\t\tloads the file \"file\" as data (d option) or as a script (s option)" (action_to_string Load);
List,Format.sprintf "\t%s;\n\t\tlists the signatures and the lexicons of the current environment" (action_to_string List);
Select,Format.sprintf "\t%s name;\n\t\tselects the name signature or lexicon in the current environment and make it an implicit context for following commands" (action_to_string Select);
Unselect,Format.sprintf "\t%s name;\n\t\tremoves any selected signature or lexicon from the context" (action_to_string Unselect);
Trace,Format.sprintf "\t%s;\n\t\ttraces the interpretation (if a command is used in a context of a lexicon) and the beta-reduction process" (action_to_string Trace);
Dont_trace,Format.sprintf "\t%s;\n\t\tstops tracing" (action_to_string Dont_trace);
Wait,Format.sprintf "\t%s;\n\t\twaits a keyboard return event before going on in executing a script" (action_to_string Trace);
Dont_wait,Format.sprintf "\t%s;\n\t\tstops waiting a keyboard return event before going on in executing a script" (action_to_string Trace);
Print,Format.sprintf "\t[name] %s;\n\t\toutputs the content of the \"name\" signature or lexicon of the current environment. If no \"name\" is specified, check whether there is a selected data in the environment" (action_to_string Print);
Analyse,Format.sprintf "\t[name1 name2 ...] %s term:type;\n\tanalyses the given \"term:type\" with respect to the given \"name1\" ... signatures or lexicons, or if no such name is given, with respect to the selected data in the environment. In the context of a signature, this command just typechecks the given entry. In the context of a lexicon, it typechecks it and interprets it with respect to this lexicon" (action_to_string Analyse);
Compose,Format.sprintf "\t%s name1 name2 as name3;\n\t\tcreates a new lexicon with name \"name3\" by composing the \"name1\" and \"name2\" lexicons" (action_to_string Compose)
]
let messages = function
| Load as command -> Format.sprintf "\t%s d|data|s|script file;\n\t\tloads the file \"file\" as data (d or data option) or as a script (script or s option)" (action_to_string command)
| List as command -> Format.sprintf "\t%s;\n\t\tlists the signatures and the lexicons of the current environment" (action_to_string command)
| Select as command -> Format.sprintf "\t%s name;\n\t\tselects the name signature or lexicon in the current environment and make it an implicit context for following commands" (action_to_string command)
| Unselect as command -> Format.sprintf "\t%s name;\n\t\tremoves any selected signature or lexicon from the context" (action_to_string command)
| Trace as command -> Format.sprintf "\t%s;\n\t\ttraces the interpretation (if a command is used in a context of a lexicon) and the beta-reduction process" (action_to_string command)
| Dont_trace as command -> Format.sprintf "\t%s;\n\t\tstops tracing" (action_to_string command)
| Wait as command -> Format.sprintf "\t%s;\n\t\twaits a keyboard return event before going on in executing a script" (action_to_string command)
| Dont_wait as command -> Format.sprintf "\t%s;\n\t\tstops waiting a keyboard return event before going on in executing a script" (action_to_string command)
| Print as command -> Format.sprintf "\t[name] %s;\n\t\toutputs the content of the \"name\" signature or lexicon of the current environment. If no \"name\" is specified, check whether there is a selected data in the environment" (action_to_string command)
| Analyse as command -> Format.sprintf "\t[name1 name2 ...] %s term:type;\n\tanalyses the given \"term:type\" with respect to the given \"name1\" ... signatures or lexicons, or if no such name is given, with respect to the selected data in the environment. In the context of a signature, this command just typechecks the given entry. In the context of a lexicon, it typechecks it and interprets it with respect to this lexicon" (action_to_string command)
| Add as command -> Format.sprintf "\t[name1 name2 ...] %s expression;\n\tadds the given \"expression\" with respect to the given \"name1\" ... signatures or lexicons to those signature or lexicons. \"expression\" must respect the syntax of signatures or lexicons" (action_to_string command)
| Compose as command -> Format.sprintf "\t%s name1 name2 as name3;\n\t\tcreates a new lexicon with name \"name3\" by composing the \"name1\" and \"name2\" lexicons" (action_to_string command)
| Help _ as command -> Format.sprintf "\t%s ;\n\t\tprints the help message" (action_to_string command)
| Create as command -> Format.sprintf "\t%s s|sig|l|lex name [name1 name2];\n\t\tcreates a new empty signature or lexicon (according to the s or sig, or l or lex option) with name \"name\" in the current environment.\"name1\" and \"name2\" are mandatory in case of creating a lexicon: they are respectively the abstract and the object signature. They of course are forbidden in case of creating a signature" (action_to_string command)
| Save as command -> Format.sprintf "\t[name1 name2 ...] %s filename;\n\t\toutputs the content of \"name1\", \"name2\"... into the same file \"filename\". If no \"name\" is specified, check whether there is a selected data in the environment" (action_to_string command)
let rec help = function
| Help (Some (Help a)) -> help (Help a)
| Help (Some a) -> Format.printf "Usage:\n%s\n" (List.assoc a help_messages)
| Help None -> Format.printf "Commands: For any command, its usage can be reminded by running the following command:\n\tcommand help;\nThe following commands are available. \n%s\n" (Utils.string_of_list "\n" (fun (_,x) -> x) help_messages)
| _ as a -> Format.printf "Usage:@\n%s@\n" (List.assoc a help_messages)
| Help (Some a) -> Format.printf "Usage:\n%s\n" (messages a)
| Help None -> Format.printf "Commands: For any command, its usage can be reminded by running the following command:\n\tcommand help;\nThe following commands are available. \n%s\n" (Utils.string_of_list "\n" (fun x -> x) (List.map messages actions))
| _ as a -> Format.printf "Usage:@\n%s@\n" (messages a)
let exit () = raise End_of_file
end
......@@ -16,10 +16,13 @@ sig
| Dont_trace
| Print
| Analyse
| Add
| Compose
| Dont_wait
| Wait
| Help of action option
| Create
| Save
......@@ -41,6 +44,8 @@ sig
val analyse : ?names:(string * (Lexing.position * Lexing.position)) list -> env -> ?offset:string -> string -> (Lexing.position * Lexing.position) -> unit
val add : ?names:(string * (Lexing.position * Lexing.position)) list -> env -> ?offset:string -> string -> (Lexing.position * Lexing.position) -> env
val compose :
string * (Lexing.position * Lexing.position) ->
string * (Lexing.position * Lexing.position) ->
......@@ -55,6 +60,16 @@ sig
val help : action -> unit
val exit : unit -> unit
val create_sig : (string * (Lexing.position * Lexing.position)) -> env -> env
val create_lex : abs:(string * (Lexing.position * Lexing.position)) -> obj:(string * (Lexing.position * Lexing.position)) -> (string * (Lexing.position * Lexing.position)) -> env -> env
val save : ?names:(string * (Lexing.position * Lexing.position)) list -> string -> env -> (Lexing.position * Lexing.position) -> unit
end
......
......@@ -18,6 +18,7 @@ type token =
| TRACE
| PRINT of Abstract_syntax.location
| ANALYSE of (string*Abstract_syntax.location*string)
| ADD of (string*Abstract_syntax.location*string)
| COMPOSE
| SEMICOLONN of string
| AS
......@@ -25,6 +26,10 @@ type token =
| WAIT
| IDENTT of (string*Abstract_syntax.location)
| HELP
| CREATE_SIG
| CREATE_LEX
| CREATE_HELP
| SAVE of (string*Abstract_syntax.location*string)
let loc lexbuf = Lexing.lexeme_start_p lexbuf,Lexing.lexeme_end_p lexbuf
......@@ -64,6 +69,7 @@ let string = (letter|digit|'_')*
| "#" {comment lexer lexbuf}
| [';'] as c {let () = echo_chr c in let s = reset_echo () in SEMICOLONN s}
| "load" as c {let () = echo_str c in let t = load_options lexbuf in t}
| "create" as c {let () = echo_str c in let t = create_options lexbuf in t}
| "list" as c {let () = echo_str c in LIST}
| "select" as c {let () = echo_str c in SELECT}
| "unselect" as c {let () = echo_str c in UNSELECT}
......@@ -72,10 +78,14 @@ let string = (letter|digit|'_')*
| "print" as c {let () = echo_str c in PRINT (loc lexbuf)}
| "analyse" as c {let () = echo_str c in let () = Buffer.reset string_content in
string (fun x l -> ANALYSE (x,l,let () = echo_str (x^";") in reset_echo ())) lexbuf}
| "add" as c {let () = echo_str c in let () = Buffer.reset string_content in
string_wo_space (fun x l -> ADD (x,l,let () = echo_str (x^";") in reset_echo ())) lexbuf}
| "compose" as c {let () = echo_str c in COMPOSE}
| "don't" as c {let () = echo_str c in DONT}
| "wait" as c {let () = echo_str c in WAIT}
| "as" as c {let () = echo_str c in AS}
| "save" as c {let () = echo_str c in let () = Buffer.reset string_content in
string_wo_space (fun x l -> SAVE (x,l,let () = echo_str (x^";") in reset_echo ())) lexbuf}
| letter string as c {let () = echo_str c in IDENTT (Lexing.lexeme lexbuf,loc lexbuf)}
| _ {raise (Scripting_errors.Error (Scripting_errors.Command_expected,loc lexbuf))}
and comment f_parser = parse
......@@ -107,4 +117,16 @@ let string = (letter|digit|'_')*
| "s" as c {let () = echo_chr c in let () = Buffer.reset string_content in
string_wo_space (fun x l -> LOAD_SCRIPT (x,l,let () = echo_str (x^";") in reset_echo ())) lexbuf}
| _ {raise (Scripting_errors.Error (Scripting_errors.Missing_option Scripting_errors.Load,loc lexbuf))}
and create_options = parse
| [' ' '\t'] {create_options lexbuf}
| newline {let () = Error.update_loc lexbuf None in create_options lexbuf}
| eof {EOII}
| "help" {CREATE_HELP}
| "#" {comment create_options lexbuf}
| "s" as c {let () = echo_chr c in let () = Buffer.reset string_content in CREATE_SIG}
| "sig" as c {let () = echo_str c in let () = Buffer.reset string_content in CREATE_SIG}
| "l" as c {let () = echo_chr c in let () = Buffer.reset string_content in CREATE_LEX}
| "lex" as c {let () = echo_str c in let () = Buffer.reset string_content in CREATE_LEX}
......@@ -39,13 +39,17 @@ TRACE
HELP
<Abstract_syntax.Abstract_syntax.location>PRINT
<(string*Abstract_syntax.Abstract_syntax.location*string)>ANALYSE
<(string*Abstract_syntax.Abstract_syntax.location*string)>ADD
COMPOSE
<string>SEMICOLONN
AS
DONT
WAIT
<(string*Abstract_syntax.Abstract_syntax.location)>IDENTT
/*<(string*Abstract_syntax.Abstract_syntax.location)>STRING*/
CREATE_SIG
CREATE_LEX
CREATE_HELP
<(string*Abstract_syntax.Abstract_syntax.location*string)>SAVE
%start <(E.t)> zzcommands
......@@ -90,10 +94,20 @@ WAIT
match names with
| [] -> let () = F.analyse e t l in e
| _ -> let () = F.analyse ~names e t l in e}
| optional_idents[names] ADD[(t,l,line)] { let () = echo line in fun e ->
match names with
| [] -> F.add e t l
| _ -> F.add ~names e t l}
| COMPOSE IDENTT[n1] IDENTT [n2] AS IDENTT[n3] SEMICOLONN[l] { let () = echo l in fun e -> F.compose n1 n2 n3 e}
| HELP SEMICOLONN[l] {let () = echo l in fun e -> let () = F.help (F.Help None) in e}
| all_commands[c] HELP SEMICOLONN[l] {let () = echo l in fun e -> let () = F.help (F.Help (Some c)) in e}
| LOAD_HELP SEMICOLONN[l] {let () = echo l in fun e -> let () = F.help (F.Help (Some F.Load)) in e}
| CREATE_SIG IDENTT[n] SEMICOLONN[l] {let () = echo l in fun e -> F.create_sig n e}
| CREATE_LEX IDENTT[n] IDENTT[n1] IDENTT[n2] SEMICOLONN[l] {let () = echo l in fun e -> F.create_lex ~abs:n1 ~obj:n2 n e}
| optional_idents[names] SAVE[(filename,l,line)] { let () = echo line in fun e ->
match names with
| [] -> let () = F.save filename e l in e
| _ -> let () = F.save ~names filename e l in e}
all_commands:
| WAIT {F.Wait}
......@@ -105,6 +119,7 @@ WAIT
| DONT TRACE {F.Dont_trace}
| PRINT {F.Print}
| ANALYSE {F.Analyse}
| ADD {F.Add}
| COMPOSE {F.Compose}
| HELP {F.Help None}
......
......@@ -9,6 +9,7 @@ type error =
| No_such_lexicon of string
| Command_expected
| Not_yet_implemented of string
| No_focus
exception Error of (error * Abstract_syntax.location)
......@@ -19,5 +20,6 @@ let error_msg er (s,e) =
| Not_in_environment s -> Printf.sprintf "No %s entry in the current environment" s
| No_such_lexicon s -> Printf.sprintf "No lexicon \"%s\" in the current environmnet" s
| Command_expected -> "Command expected"
| No_focus -> "No data on which to apply the command"
| Not_yet_implemented s -> Printf.sprintf "\"%s\": Command not yet implemented" s in
Printf.sprintf "%s:\n%s\n%!" loc msg
......@@ -7,6 +7,7 @@ type error =
| No_such_lexicon of string
| Command_expected
| Not_yet_implemented of string
| No_focus
exception Error of (error * (Lexing.position * Lexing.position))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment