aboutsummaryrefslogtreecommitdiff
path: root/ide
diff options
context:
space:
mode:
authorEnrico Tassi2019-06-17 20:57:02 +0200
committerEnrico Tassi2019-06-19 11:29:33 +0200
commitbcc790edb63af62022699c8005b522b45f0e81cd (patch)
tree83495d8db0c7a3a1f39cb5c321eddd39841b7cf9 /ide
parent535d897ed25f37d454b119a3873a2ff232d3f46e (diff)
[ide] chop sentences taking into account QUOTATION token
Diffstat (limited to 'ide')
-rw-r--r--ide/coq_lex.mll47
1 files changed, 47 insertions, 0 deletions
diff --git a/ide/coq_lex.mll b/ide/coq_lex.mll
index b6654f6d7a..dbdfc5627e 100644
--- a/ide/coq_lex.mll
+++ b/ide/coq_lex.mll
@@ -50,6 +50,41 @@ and comment = parse
| utf8_extra_byte { incr utf8_adjust; comment lexbuf }
| _ { comment lexbuf }
+and quotation o c n l = parse | eof { raise Unterminated } | _ {
+ let x = Lexing.lexeme lexbuf in
+ if x = o then quotation_nesting o c n l 1 lexbuf
+ else if x = c then
+ if n = 1 && l = 1 then ()
+ else quotation_closing o c n l 1 lexbuf
+ else quotation o c n l lexbuf
+}
+
+and quotation_nesting o c n l v = parse | eof { raise Unterminated } | _ {
+ let x = Lexing.lexeme lexbuf in
+ if x = o then
+ if n = v+1 then quotation o c n (l+1) lexbuf
+ else quotation_nesting o c n l (v+1) lexbuf
+ else if x = c then quotation_closing o c n l 1 lexbuf
+ else quotation o c n l lexbuf
+}
+
+and quotation_closing o c n l v = parse | eof { raise Unterminated } | _ {
+ let x = Lexing.lexeme lexbuf in
+ if x = c then
+ if n = v+1 then
+ if l = 1 then ()
+ else quotation o c n (l-1) lexbuf
+ else quotation_closing o c n l (v+1) lexbuf
+ else if x = o then quotation_nesting o c n l 1 lexbuf
+ else quotation o c n l lexbuf
+}
+
+and quotation_start o c n = parse | eof { raise Unterminated } | _ {
+ let x = Lexing.lexeme lexbuf in
+ if x = o then quotation_start o c (n+1) lexbuf
+ else quotation o c n 1 lexbuf
+}
+
(** NB : [mkiter] should be called on increasing offsets *)
and sentence initial stamp = parse
@@ -83,6 +118,18 @@ and sentence initial stamp = parse
if initial then stamp (utf8_lexeme_start lexbuf + String.length (Lexing.lexeme lexbuf) - 1) Tags.Script.sentence;
sentence initial stamp lexbuf
}
+ | ['a'-'z' 'A'-'Z'] ":{" {
+ quotation_start "{" "}" 1 lexbuf;
+ sentence false stamp lexbuf
+ }
+ | ['a'-'z' 'A'-'Z'] ":[" {
+ quotation_start "[" "]" 1 lexbuf;
+ sentence false stamp lexbuf
+ }
+ | ['a'-'z' 'A'-'Z'] ":(" {
+ quotation_start "(" ")" 1 lexbuf;
+ sentence false stamp lexbuf
+ }
| space+ {
(* Parsing spaces is the only situation preserving initiality *)
sentence initial stamp lexbuf