Skip to content

Commit

Permalink
wip: use regex to escape identifiers in TPTP output (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
abentkamp committed Oct 28, 2022
1 parent 9d33336 commit 1dd88f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/core/Util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,8 @@ let pp_list0 ?(sep=" ") pp_x out = function

let tstp_needs_escaping s =
assert (s<>"");
s.[0] = '_' ||
CCString.exists
(function
| ' ' | '#' | '$' | '+' | '-' | '/' | '\n'
| '\t' | '\r' | '<' | '>' -> true
| _ -> false)
s
let idregex = Str.regexp "^[a-zA-Z]+[a-zA-Z0-9_]*$" in
not (Str.string_match idregex s 0)

let pp_str_tstp out s =
CCFormat.string out (if tstp_needs_escaping s then "'" ^ String.escaped s ^ "'" else s)
Expand Down
2 changes: 1 addition & 1 deletion src/core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(public_name logtk)
(synopsis "core data structures and algorithms for Logtk")
(libraries containers containers-data iter oseq
unix mtime mtime.clock.os logtk.arith)
unix mtime mtime.clock.os logtk.arith str)
(flags :standard -w -32-50 -open Logtk_arith)
(c_names util_stubs)
(c_flags -Wextra -Wno-unused-parameter)
Expand Down

0 comments on commit 1dd88f9

Please sign in to comment.