Commit f4da0e11 authored by Jacques-Henri Jourdan's avatar Jacques-Henri Jourdan
Browse files

Merge branch 'master' of gitlab.inria.fr:fpottier/menhir

parents 5f195649 aa0b25fc
Pipeline #83687 passed with stages
in 26 seconds
# Changes
## 2019/06/20
* When compiled with OCaml 4.02.3, Menhir could produce OCaml code
containing invalid string literals. This was due to a problem in
`String.escaped`. Fixed. (Reported by ELLIOTCABLE.)
## 2019/06/13
* Relax the syntax of point-free actions to allow `< >` (with arbitrary
......
......@@ -277,7 +277,7 @@ ARCHIVE := $(REPO)/repository/$(DATE)/archive.tar.gz
# Additional options for coq-menhirlib.
COQ_MENHIRLIB_PUBLISH_OPTIONS := \
--repo coq/opam-coq-archive \
--packages-directory packages/released \
--packages-directory released/packages \
.PHONY: opam
opam:
......
This source diff could not be displayed because it is too large. You can view the blob instead.
module Bytes = struct
include Bytes
let escaped s =
let n = ref 0 in
for i = 0 to length s - 1 do
n := !n +
(match unsafe_get s i with
| '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2
| ' ' .. '~' -> 1
| _ -> 4)
done;
if !n = length s then copy s else begin
let s' = create !n in
n := 0;
for i = 0 to length s - 1 do
begin match unsafe_get s i with
| ('\"' | '\\') as c ->
unsafe_set s' !n '\\'; incr n; unsafe_set s' !n c
| '\n' ->
unsafe_set s' !n '\\'; incr n; unsafe_set s' !n 'n'
| '\t' ->
unsafe_set s' !n '\\'; incr n; unsafe_set s' !n 't'
| '\r' ->
unsafe_set s' !n '\\'; incr n; unsafe_set s' !n 'r'
| '\b' ->
unsafe_set s' !n '\\'; incr n; unsafe_set s' !n 'b'
| (' ' .. '~') as c -> unsafe_set s' !n c
| c ->
let a = Char.code c in
unsafe_set s' !n '\\';
incr n;
unsafe_set s' !n (Char.chr (48 + a / 100));
incr n;
unsafe_set s' !n (Char.chr (48 + (a / 10) mod 10));
incr n;
unsafe_set s' !n (Char.chr (48 + a mod 10));
end;
incr n
done;
s'
end
end
module String = struct
open String
let escaped s =
let rec escape_if_needed s n i =
if i >= n then s else
match unsafe_get s i with
| '\"' | '\\' | '\000'..'\031' | '\127'.. '\255' ->
Bytes.unsafe_to_string (Bytes.escaped (Bytes.unsafe_of_string s))
| _ -> escape_if_needed s n (i+1)
in
escape_if_needed s (length s) 0
end
(* The standard library function [String.escaped] in OCaml 4.02.3 depends
on the operating system function [isprint] and therefore can have OS-
dependent, locale-dependent behavior. This issue has been fixed in OCaml
4.03. We use a copy of the code found in OCaml 4.03 and higher, so as to
avoid this issue. *)
module Bytes : sig
val escaped: bytes -> bytes
end
module String : sig
val escaped: string -> string
end
......@@ -398,7 +398,7 @@ and exprk k f e =
else
fprintf f "(%d)" k
| EStringConst s ->
fprintf f "\"%s\"" (String.escaped s)
fprintf f "\"%s\"" (Compatibility.String.escaped s)
| ETuple [] ->
assert false
| ETuple [ e ] ->
......
......@@ -58,13 +58,13 @@ font-size: 1rem;
}
</style>
<title>Menhir Reference Manual
(version 20190613)
(version 20190620)
</title>
</head>
<body >
<!--HEVEA command line is: hevea -fix manual.tex -->
<!--CUT STYLE article--><!--CUT DEF section 1 --><table class="title"><tr><td style="padding:1ex"><h1 class="titlemain">Menhir Reference Manual<br>
(version 20190613)</h1><h3 class="titlerest">François Pottier and Yann Régis-Gianas<br>
(version 20190620)</h1><h3 class="titlerest">François Pottier and Yann Régis-Gianas<br>
INRIA<br>
<span style="font-family:monospace">{Francois.Pottier, Yann.Regis-Gianas}@inria.fr</span></h3></td></tr>
</table><!--TOC section id="sec1" Contents-->
......
No preview for this file type
www/doc/manual001.png

4.33 KB | W: | H:

www/doc/manual001.png

4.33 KB | W: | H:

www/doc/manual001.png
www/doc/manual001.png
www/doc/manual001.png
www/doc/manual001.png
  • 2-up
  • Swipe
  • Onion skin
www/doc/manual002.png

4.14 KB | W: | H:

www/doc/manual002.png

4.14 KB | W: | H:

www/doc/manual002.png
www/doc/manual002.png
www/doc/manual002.png
www/doc/manual002.png
  • 2-up
  • Swipe
  • Onion skin
www/doc/manual003.png

5.14 KB | W: | H:

www/doc/manual003.png

5.14 KB | W: | H:

www/doc/manual003.png
www/doc/manual003.png
www/doc/manual003.png
www/doc/manual003.png
  • 2-up
  • Swipe
  • Onion skin
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment