/[svn]/parser/parser.ml
ViewVC logotype

Diff of /parser/parser.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 324 by abate, Tue Jul 10 17:24:58 2007 UTC revision 325 by abate, Tue Jul 10 17:25:18 2007 UTC
# Line 38  Line 38 
38    
39  let seq_of_string pos s =  let seq_of_string pos s =
40    let s =  Encodings.Utf8.mk s in    let s =  Encodings.Utf8.mk s in
   (* What about locations when input file is not Utf8 ?  
      Or when using special characters in string ! *)  
41    let (pos,_) = pos in    let (pos,_) = pos in
42    let rec aux pos i j =    let rec aux pos i j =
43      if Encodings.Utf8.equal_index i j then []      if Encodings.Utf8.equal_index i j then []
44      else      else
45          let (len,i) = Encodings.Utf8.next s i in
46        let (c,i) = Encodings.Utf8.next s i in        let (c,i) = Encodings.Utf8.next s i in
47        ((pos,pos+1),c)::(aux (pos+1) i j)        ((pos,pos+len),c) :: (aux (pos + len) i j)
48    in    in
49    aux (pos + 1) (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s)    aux (pos + 1) (Encodings.Utf8.start_index s) (Encodings.Utf8.end_index s)
50    
# Line 58  Line 57 
57  let parse_char loc s =  let parse_char loc s =
58    let s = seq_of_string loc s in    let s = seq_of_string loc s in
59    match s with    match s with
60      | [_,c] -> c      | [ loc,c ] -> c
61      | _ -> error loc "Character litteral must have length 1"      | _ -> error loc "Character litteral must have length 1"
62    
63  let char_list pos s =  let char_list loc s =
64    let s = seq_of_string pos s in    let s = seq_of_string loc s in
65    List.map (fun (loc,c) -> exp loc (Cst (Types.Char (Chars.mk_int c)))) s    List.map (fun (loc,c) -> exp loc (Cst (Types.Char (Chars.mk_int c)))) s
66    
67    

Legend:
Removed from v.324  
changed lines
  Added in v.325

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5