Skip to content

Commit

Permalink
Add missing parentheses around ( or )
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow committed Jan 8, 2025
1 parent 7a8994c commit 45d36eb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/model/names.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ let operator_char = function
true
| _ -> false

let parenthesise name =
match name with
| "asr" | "land" | "lor" | "lsl" | "lsr" | "lxor" | "mod" -> "(" ^ name ^ ")"
| _ -> if String.exists operator_char name then "(" ^ name ^ ")" else name
let is_operator = function
| "asr" | "land" | "lor" | "lsl" | "lsr" | "lxor" | "mod" | "or" -> true
| name -> String.exists operator_char name

let parenthesise name = if is_operator name then "(" ^ name ^ ")" else name

let contains_double_underscore s =
let len = String.length s in
Expand Down
2 changes: 2 additions & 0 deletions src/ocamlary/ocamlary.mli
Original file line number Diff line number Diff line change
Expand Up @@ -1078,4 +1078,6 @@ module Op : sig
val ( .%{;..}<- ) : int
val ( !~ ) : int
val ( #~ ) : int
val ( or ) : int
val ( lsl ) : int
end
12 changes: 12 additions & 0 deletions test/generators/html/Ocamlary-Op.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ <h1>Module <code><span>Ocamlary.Op</span></code></h1>
<code><span><span class="keyword">val</span> (#~) : int</span></code>
</div>
</div>
<div class="odoc-spec">
<div class="spec value anchored" id="val-(or)">
<a href="#val-(or)" class="anchor"></a>
<code><span><span class="keyword">val</span> (or) : int</span></code>
</div>
</div>
<div class="odoc-spec">
<div class="spec value anchored" id="val-(lsl)">
<a href="#val-(lsl)" class="anchor"></a>
<code><span><span class="keyword">val</span> (lsl) : int</span></code>
</div>
</div>
</div>
</body>
</html>
2 changes: 2 additions & 0 deletions test/generators/latex/Ocamlary.tex
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,8 @@ \subsection{New reference syntax\label{new-reference-syntax}}%
\label{Ocamlary-Op-val-(.+p++ob+;..+cb+<-)}\ocamlcodefragment{\ocamltag{keyword}{val} (.\allowbreak{}\%\{;\allowbreak{}.\allowbreak{}.\allowbreak{}\}<-) : int}\\
\label{Ocamlary-Op-val-(!+t+)}\ocamlcodefragment{\ocamltag{keyword}{val} (!\textasciitilde{}) : int}\\
\label{Ocamlary-Op-val-(#+t+)}\ocamlcodefragment{\ocamltag{keyword}{val} (\#\textasciitilde{}) : int}\\
\label{Ocamlary-Op-val-(or)}\ocamlcodefragment{\ocamltag{keyword}{val} (or) : int}\\
\label{Ocamlary-Op-val-(lsl)}\ocamlcodefragment{\ocamltag{keyword}{val} (lsl) : int}\\
\end{ocamlindent}%
\ocamlcodefragment{\ocamltag{keyword}{end}}\\

Expand Down
4 changes: 4 additions & 0 deletions test/generators/man/Ocamlary.Op.3o
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Ocamlary\.Op
\f[CB]val\fR (!~) : int
.sp
\f[CB]val\fR (#~) : int
.sp
\f[CB]val\fR (or) : int
.sp
\f[CB]val\fR (lsl) : int

0 comments on commit 45d36eb

Please sign in to comment.