Commit 05bfeab4 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-11 08:18:39 by cvscast] Better localization of characters in strings

Original author: cvscast
Date: 2003-05-11 08:18:39+00:00
parent 3e8299c7
......@@ -48,6 +48,20 @@ let seq_of_string pos s =
in
aux (pos+1) (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s)
let get_string s =
let s = Encodings.Utf8.mk s in
let b = Buffer.create 32 in
let rec aux i j =
if Encodings.Utf8.equal_index i j then ()
else
let (len,i) = Encodings.Utf8.next s i in
let (c,i) = Encodings.Utf8.next s i in
Encodings.Utf8.store b c;
aux i j
in
aux (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s);
Buffer.contents b
exception Error of string
let error (i,j) s = Location.raise_loc i j (Error s)
......@@ -81,6 +95,7 @@ EXTEND
| LIDENT "type"; x = UIDENT; "="; t = pat -> [ mk loc (TypeDecl (x,t)) ]
| LIDENT "debug"; d = debug_directive -> [ mk loc (Debug d) ]
| LIDENT "include"; s = STRING2 ->
let s = get_string s in
protect_op "File inclusion";
(* avoid looping; should issue an error ? *)
if List.mem s !include_stack then []
......
Markdown is supported
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