module Ast = GrafiteAst
module Pt = CicNotationPt
+ (* set to false to change identifier instead of adding extra identifiers *)
+let add_ident = ref true
+
let error_token = "O"
let error_token_len = String.length error_token
(sanitize_tokens [] tokens) in
List.nth idents (Random.int (List.length idents))
in
- let start_pos, end_pos =
+ let start_pos, end_pos = (* positions in bytecount *)
Glib.Utf8.offset_to_pos statement 0 (Stdpp.first_pos target_pos),
Glib.Utf8.offset_to_pos statement 0 (Stdpp.last_pos target_pos) in
let statement' =
- (* positions in bytecount *)
- String.sub statement 0 start_pos
- ^ "O"
- ^ String.sub statement end_pos (String.length statement - end_pos) in
+ if !add_ident then
+ String.sub statement 0 start_pos
+ ^ "O "
+ ^ String.sub statement start_pos (String.length statement - start_pos)
+ else
+ String.sub statement 0 start_pos
+ ^ "O"
+ ^ String.sub statement end_pos (String.length statement - end_pos)
+ in
let script = HExtlib.input_file fname in
let matches =
let rex =
let trailer = (* trailing comment with machine parseable error location *)
let preamble_len = Glib.Utf8.length matches.(1) in
sprintf "\n(*\nerror-at: %d-%d\n*)\n"
- (preamble_len + Stdpp.first_pos target_pos)
- (preamble_len + Stdpp.first_pos target_pos + error_token_len) in
- let script' = sprintf "%s%s%s%s" matches.(1) statement' matches.(3) trailer in
+ (preamble_len + Stdpp.first_pos target_pos)
+ (preamble_len + Stdpp.first_pos target_pos + error_token_len) in
+ let script' =
+ sprintf "%s%s%s%s" matches.(1) statement' matches.(3) trailer in
let md5 = Digest.to_hex (Digest.string script') in
HExtlib.output_file
~filename:(sprintf "%s.%s.rottened" fname md5)