39 lines
1.2 KiB
Diff
39 lines
1.2 KiB
Diff
|
From d3226b70359cb8618d95d1105c908aa591f1b144 Mon Sep 17 00:00:00 2001
|
||
|
From: Jeremie Dimino <jdimino@janestreet.com>
|
||
|
Date: Thu, 17 Apr 2014 10:55:43 +0100
|
||
|
Subject: [PATCH] Fix ocaml/camlp4#19
|
||
|
|
||
|
---
|
||
|
syntax/pa_optcomp.ml | 10 ++++++++--
|
||
|
1 file changed, 8 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/syntax/pa_optcomp.ml b/syntax/pa_optcomp.ml
|
||
|
index 583248f..4b112d2 100644
|
||
|
--- a/syntax/pa_optcomp.ml
|
||
|
+++ b/syntax/pa_optcomp.ml
|
||
|
@@ -334,13 +334,19 @@ let parse_ident stream =
|
||
|
let parse_expr stream =
|
||
|
(* Lists of opened brackets *)
|
||
|
let opened_brackets = ref [] in
|
||
|
+ let eoi = ref None in
|
||
|
|
||
|
(* Return the next token of [stream] until all opened parentheses
|
||
|
have been closed and a newline is reached *)
|
||
|
let rec next_token _ =
|
||
|
- Some(match Stream.next stream, !opened_brackets with
|
||
|
+ match !eoi with
|
||
|
+ | Some _ as x -> x
|
||
|
+ | None ->
|
||
|
+ Some(match Stream.next stream, !opened_brackets with
|
||
|
| (NEWLINE, loc), [] ->
|
||
|
- EOI, loc
|
||
|
+ let x = EOI, loc in
|
||
|
+ eoi := Some x;
|
||
|
+ x
|
||
|
|
||
|
| (KEYWORD("(" | "[" | "{" as b), _) as x, l ->
|
||
|
opened_brackets := b :: l;
|
||
|
--
|
||
|
1.9.3
|
||
|
|