...
 
Commits (7)
......@@ -7,9 +7,15 @@ struct
let compare (Var i) (Var j)=i-j
let succ (Var i)=Var (i+1)
let start=Var 0
let to_string (Var i) =
let c = Printf.sprintf "%c" (char_of_int (97+i)) in
c
let to_string (Var i) =
let dec = decompose ~input:i ~base:26 in
List.fold_left
(fun acc i ->
Printf.sprintf "%s%c" acc (char_of_int (97+i)))
""
dec
(* let c = Printf.sprintf "%c" (char_of_int (97+i)) in
c *)
end
......
......@@ -3,14 +3,16 @@
}
let newline = ('\010' | '\013' | "\013\010")
let letter = ['a'-'z' 'A'-'Z']
let letter = ['a'-'z' 'A'-'Z' 'µ' 'À'-'Ö' 'Ø'-'Ý' 'ß'-'ö' 'ø'-'ÿ']
let digit = ['0'-'9']
let string = (letter|digit|'_')*'\''*
let symbol = ['|' '!' '"' '#' '$' '%' '&' '\'' '*' '+' '-' '/' '<' '>' '?' '@' '\\' '^' '`' '~' ]
rule lexer =
parse
| [' ' '\t'] {lexer lexbuf}
| newline {lexer lexbuf}
| newline {let () = Lexing.new_line lexbuf in lexer lexbuf}
| "(*" {comment 1 lexbuf}
| "*)" {failwith "Unstarted comments"}
| eof {EOI}
......@@ -22,6 +24,7 @@ let string = (letter|digit|'_')*'\''*
| "/" {SLASH}
| "?" {QUESTION_MARK}
| letter string {IDENT (Lexing.lexeme lexbuf)}
| symbol {IDENT (Lexing.lexeme lexbuf)}
| '-'?digit+ {let s = Lexing.lexeme lexbuf in
INT (int_of_string s)}
and comment level =
......
......@@ -89,7 +89,7 @@ let options =
]
let () =
let () = UtilsLib.Log.set_level Logs.Debug in
let () = UtilsLib.Log.set_level "db_test" Logs.App in
if Array.length (Sys.argv) > 1 then
Arg.parse options (fun s -> parse_file !query !edb_file s) usage_msg
else parse_file None None "/home/pogodall/work/dev/ACGtk/src/datalog.prover/Jean-regarde-telescope.dl"
......@@ -74,7 +74,7 @@ let () =
let () = print_newline()
let () =
let () = UtilsLib.Log.set_level Logs.Debug in
let () = UtilsLib.Log.set_level "test" Logs.Debug in
OddIntArray.collect_results
(fun _ res -> Printf.printf "State: %s\n%!" (string_of_res res))
()
......
......@@ -253,6 +253,9 @@ struct
| Link_to variable -> assert (representative_index=variable)
| _ -> () in true));
(representative_index,representative_value),updated_f
| exception S.Store_Not_found ->
let () = Log.debug (fun m -> m "Could not find %d in the store." i) in
raise S.Store_Not_found
(** [find i h] returns a pair [(i',v),f'] where [i'] is the index of
the representative of the data indexed by [i]. [i=i'] means that
......@@ -393,7 +396,7 @@ struct
let make n d = make_aux n d IntMap.empty
let get k m =
let get k m =
try
IntMap.find k m
with
......
......@@ -15,7 +15,8 @@ struct
if !bufpos >= String.length !buffer then
begin
let newbuffer = String.make (2 * !bufpos) ' ' in
String.blit !buffer 0 newbuffer 0 !bufpos; buffer := newbuffer
String.blit !buffer 0 newbuffer 0 !bufpos;
buffer := newbuffer
end;
String.set !buffer !bufpos c;
incr bufpos
......
This diff is collapsed.
......@@ -3,7 +3,6 @@
(ocamllex data_lexer term_lexer)
(menhir
; (flags (--explain --table --compile-errors /home/pogodall/work/dev/ACGtk/src/grammars/term_parser_test.messages))
(flags (--explain --table))
(modules term_parser_test))
......@@ -12,21 +11,18 @@
(flags (--explain --table --strict))
(modules file_parser sig_parser lex_parser term_type_parser bound_term_parser))
;; Rule to generate the messages ml file
(rule
(targets messages.ml)
(mode promote)
(deps
(alias update)
(alias check)
(alias check_all_messages)
(:message_file data_parser.messages)
(:parsers file_parser.mly lex_parser.mly sig_parser.mly term_type_parser.mly bound_term_parser.mly)
)
(action
(with-stdout-to messages.ml (run menhir --base data_parser --explain --table --compile-errors %{message_file} %{parsers})))
(with-stdout-to messages.ml (run menhir --base data_parser --compile-errors %{message_file} %{parsers})))
)
;; Rule to generate the automatic message file
......@@ -34,14 +30,14 @@
(targets data_parser.messages.automatic)
(deps (:parsers file_parser.mly lex_parser.mly sig_parser.mly term_type_parser.mly bound_term_parser.mly))
(action
(with-stdout-to data_parser.messages.automatic (run menhir --base data_parser --explain --table --list-errors %{parsers})))
(with-stdout-to data_parser.messages.automatic (run menhir --base data_parser --list-errors %{parsers})))
)
;; Rule to generate the message file
(rule
(targets data_parser.messages.new)
(deps (:parsers file_parser.mly lex_parser.mly sig_parser.mly term_type_parser.mly bound_term_parser.mly))
(action (with-stdout-to data_parser.messages.new (run menhir --base data_parser --explain --table --update-errors data_parser.messages %{parsers}))
(action (with-stdout-to data_parser.messages.new (run menhir --base data_parser --update-errors data_parser.messages %{parsers}))
)
)
......@@ -51,13 +47,13 @@
)
(alias
(name check)
(name check_all_messages)
(deps
data_parser.messages.automatic
data_parser.messages
(:parsers file_parser.mly lex_parser.mly sig_parser.mly term_type_parser.mly bound_term_parser.mly)
)
(action (run menhir --base data_parser --explain --table --compare-errors data_parser.messages.automatic --compare-errors data_parser.messages %{parsers}))
(action (run menhir --base data_parser --compare-errors data_parser.messages.automatic --compare-errors data_parser.messages %{parsers}))
)
;; This stanza declares the Grammar library
......
......@@ -137,7 +137,8 @@ let wait = Unix.sleep
let _ =
let () = Log.set_level ~app:"acg" Logs.Warning in
let () = Log.set_level ~app:"acg" Logs.Warning in
(*let () = Log.set_level ~app:"acg" Logs.Debug in *)
(*
let c = Mtime_clock.counter () in
Logs.info (fun m -> m "Starting run");
......
This diff is collapsed.
......@@ -13,7 +13,7 @@
(mode promote)
(deps
(alias update)
(alias check)
(alias check_all_messages)
(:message_file command_parser.messages)
(:parser command_parser.mly)
)
......@@ -43,7 +43,7 @@
)
(alias
(name check)
(name check_all_messages)
(deps
command_parser.messages.automatic
command_parser.messages
......
......@@ -704,8 +704,8 @@ module Functions =
| None -> ()
| Some (obj_t,abs_ty) ->
let () = Logs.app (fun m -> m
"The datalog program (intensional database) corresponding to the lexicon \"%s\" is:"
(fst (Env.Lexicon.name lex))) in
"The datalog program (extensional database) corresponding to the query \"%s\" is:"
data) in
Env.Lexicon.query_to_log Logs.default Logs.App obj_t abs_ty lex
......
......@@ -168,3 +168,12 @@ let log_iteration log_function s =
log_function
(Bolt.Utils.split "\n" s)
*)
let decompose ~input ~base =
let rec decompose_aux i b res =
let q = i / b in
let r = i mod b in
match q with
| 0 -> r::res
| _ -> decompose_aux q base (r::res) in
decompose_aux input base []
......@@ -97,3 +97,8 @@ val (>>) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c)
NONE *)
(*val log_iteration : (string -> unit) -> string -> unit *)
(** [decompose ~input:i ~base:b] returns the decomposition of [i] in
the base [b] as a list of integers (between [0] and [b]). *)
val decompose : input:int -> base:int -> int list