Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
POTTIER Francois
menhir
Commits
07882a52
Commit
07882a52
authored
Oct 06, 2018
by
POTTIER Francois
Browse files
Introduce `Misc.array_for_all` as a replacement for `Array.for_all`,
which does not exist in OCaml 4.02.
parent
3342a1ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/grammarFunctor.ml
View file @
07882a52
...
...
@@ -679,7 +679,7 @@ module Production = struct
production_level
.
(
k
)
<-
branch
.
branch_production_level
;
prec_decl
.
(
k
)
<-
branch
.
branch_prec_annotation
;
positions
.
(
k
)
<-
[
branch
.
branch_position
];
if
not
(
A
rray
.
for_all
Symbol
.
non_error
rhs
)
then
if
not
(
Misc
.
a
rray
_
for_all
Symbol
.
non_error
rhs
)
then
grammar_uses_error_token
:=
true
;
k
+
1
)
k
branches
in
...
...
src/misc.ml
View file @
07882a52
...
...
@@ -382,3 +382,14 @@ let nth = function
|
2
->
"second"
|
3
->
"third"
|
i
->
Printf
.
sprintf
"%dth"
i
(* To keep compatibility with OCaml 4.02,
we copy [Array.for_all], which appeared
in 4.03. *)
let
array_for_all
p
a
=
let
n
=
Array
.
length
a
in
let
rec
loop
i
=
if
i
=
n
then
true
else
if
p
(
Array
.
unsafe_get
a
i
)
then
loop
(
succ
i
)
else
false
in
loop
0
src/misc.mli
View file @
07882a52
...
...
@@ -188,3 +188,7 @@ end
(* A nice way of printing "nth" in English, for concrete values of [n]. *)
val
nth
:
int
->
string
(* [Array.for_all] *)
val
array_for_all
:
(
'
a
->
bool
)
->
'
a
array
->
bool
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment