Project

General

Profile

« Previous | Next » 

Revision ca7ff3f7

Added by LĂ©lio Brun 8 months ago

reformatting

View differences:

src/utils/location.ml
10 10
(********************************************************************)
11 11

  
12 12
open Lexing
13

  
14 13
module Lex = MenhirLib.LexerUtil
15 14

  
16 15
type t = position * position
......
22 21
let set_input, get_input, get_module =
23 22
  let input_name : filename ref = ref "__UNINITIALIZED__" in
24 23
  let module_name : filename ref = ref "__UNINITIALIZED__" in
25
  (fun name -> input_name := name; module_name := Filename.chop_extension name),
26
  (fun () -> !input_name),
27
  (fun () -> !module_name)
24
  ( (fun name ->
25
      input_name := name;
26
      module_name := Filename.chop_extension name),
27
    (fun () -> !input_name),
28
    fun () -> !module_name )
28 29

  
29
let curr lexbuf =
30
  lexbuf.lex_start_p, lexbuf.lex_curr_p
30
let curr lexbuf = lexbuf.lex_start_p, lexbuf.lex_curr_p
31 31

  
32
let filename_of_loc (s, _) =
33
  s.pos_fname
32
let filename_of_loc (s, _) = s.pos_fname
34 33

  
35
let filename_of_lexbuf lexbuf =
36
  lexbuf.lex_start_p.pos_fname
34
let filename_of_lexbuf lexbuf = lexbuf.lex_start_p.pos_fname
37 35

  
38 36
(* let init lexbuf fname =
39 37
 *   lexbuf.Lexing.lex_curr_p <- {
......
49 47
  {
50 48
    pos_fname = pos1.pos_fname;
51 49
    pos_lnum = pos1.pos_lnum + pos2.pos_lnum - 1;
52

  
53 50
    (* New try *)
54 51
    (* pos_bol = pos2.pos_bol; *)
55 52
    pos_bol = pos1.pos_bol + pos2.pos_bol;
56
    pos_cnum = pos1.pos_cnum + pos2.pos_cnum
57
    (* pos_cnum = pos2.pos_cnum; *)
58
    (*
59
    pos_bol = pos1.pos_bol + pos2.pos_bol;
60
    pos_cnum =if pos2.pos_lnum = 1 then pos1.pos_cnum + pos2.pos_cnum else pos2.pos_cnum
61
     *)
53
    pos_cnum =
54
      pos1.pos_cnum + pos2.pos_cnum
55
      (* pos_cnum = pos2.pos_cnum; *)
56
      (* pos_bol = pos1.pos_bol + pos2.pos_bol; pos_cnum =if pos2.pos_lnum = 1
57
         then pos1.pos_cnum + pos2.pos_cnum else pos2.pos_cnum *);
62 58
  }
63 59

  
64

  
65 60
(* let print loc =
66 61
 *   let filename = loc.loc_start.pos_fname in
67 62
 *   let line = loc.loc_start.pos_lnum in
......
84 79
 *   print_newline () *)
85 80

  
86 81
let loc_line (s, _e) = s.pos_lnum
87
  
82

  
88 83
let pp_loc fmt loc =
89
  if loc == dummy_loc then
90
    ()
91
  else
92
    Format.fprintf fmt "%s" (Lex.range loc)
84
  if loc == dummy_loc then () else Format.fprintf fmt "%s" (Lex.range loc)
93 85

  
94 86
let pp_c_loc fmt (s, _e) =
95 87
  let filename = s.pos_fname in
96 88
  let line = s.pos_lnum in
97 89
  Format.fprintf fmt "#line %i \"%s\"" line filename
98 90

  
99
let shift (_s1, e1) (s2, e2) =
100
  shift_pos e1 s2,
101
  shift_pos e1 e2
91
let shift (_s1, e1) (s2, e2) = shift_pos e1 s2, shift_pos e1 e2
102 92

  
103 93
(* Local Variables: *)
104 94
(* compile-command:"make -C .." *)

Also available in: Unified diff