Commit 50bdf62d authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-09-17 22:04:50 by cvscast] Empty log message

Original author: cvscast
Date: 2003-09-17 22:04:50+00:00
parent ff176a7f
...@@ -74,6 +74,13 @@ let nb_classes = 40 ...@@ -74,6 +74,13 @@ let nb_classes = 40
# 17 "parser/wlexer.mll" # 17 "parser/wlexer.mll"
(* the new Lexing lib in OCaml 3.07 has a different handling of
locations. The following functions simulate the old behavior *)
let lexeme_start lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_start_pos
let lexeme_end lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_curr_pos
let keywords = Hashtbl.create 17 let keywords = Hashtbl.create 17
let in_comment = ref false let in_comment = ref false
...@@ -123,7 +130,7 @@ let nb_classes = 40 ...@@ -123,7 +130,7 @@ let nb_classes = 40
aux 0 0 aux 0 0
# 127 "parser/wlexer.ml" # 134 "parser/wlexer.ml"
let __ocaml_lex_tables = { let __ocaml_lex_tables = {
Lexing.lex_base = Lexing.lex_base =
"\000\000\246\255\245\255\008\000\036\000\007\000\250\255\005\000\ "\000\000\246\255\245\255\008\000\036\000\007\000\250\255\005\000\
...@@ -209,50 +216,50 @@ let __ocaml_lex_tables = { ...@@ -209,50 +216,50 @@ let __ocaml_lex_tables = {
let rec token engine lexbuf = let rec token engine lexbuf =
match engine __ocaml_lex_tables 0 lexbuf with match engine __ocaml_lex_tables 0 lexbuf with
| 0 -> | 0 ->
# 78 "parser/wlexer.mll" # 85 "parser/wlexer.mll"
( token engine lexbuf ) ( token engine lexbuf )
# 215 "parser/wlexer.ml" # 222 "parser/wlexer.ml"
| 1 -> | 1 ->
# 80 "parser/wlexer.mll" # 87 "parser/wlexer.mll"
( (
let s = Lexing.lexeme lexbuf in let s = Lexing.lexeme lexbuf in
if Hashtbl.mem keywords s then "",s else "IDENT",s if Hashtbl.mem keywords s then "",s else "IDENT",s
) )
# 223 "parser/wlexer.ml" # 230 "parser/wlexer.ml"
| 2 -> | 2 ->
# 85 "parser/wlexer.mll" # 92 "parser/wlexer.mll"
( (
let s = Lexing.lexeme lexbuf in let s = Lexing.lexeme lexbuf in
let s = String.sub s 0 (String.length s - 2) in let s = String.sub s 0 (String.length s - 2) in
"ANY_IN_NS", s "ANY_IN_NS", s
) )
# 232 "parser/wlexer.ml" # 239 "parser/wlexer.ml"
| 3 -> | 3 ->
# 90 "parser/wlexer.mll" # 97 "parser/wlexer.mll"
( "ANY_IN_NS", "" ) ( "ANY_IN_NS", "" )
# 237 "parser/wlexer.ml" # 244 "parser/wlexer.ml"
| 4 -> | 4 ->
# 92 "parser/wlexer.mll" # 99 "parser/wlexer.mll"
( "INT",Lexing.lexeme lexbuf ) ( "INT",Lexing.lexeme lexbuf )
# 242 "parser/wlexer.ml" # 249 "parser/wlexer.ml"
| 5 -> | 5 ->
# 97 "parser/wlexer.mll" # 104 "parser/wlexer.mll"
( "",Lexing.lexeme lexbuf ) ( "",Lexing.lexeme lexbuf )
# 247 "parser/wlexer.ml" # 254 "parser/wlexer.ml"
| 6 -> | 6 ->
# 98 "parser/wlexer.mll" # 105 "parser/wlexer.mll"
( "DIRECTIVE",Lexing.lexeme lexbuf ) ( "DIRECTIVE",Lexing.lexeme lexbuf )
# 252 "parser/wlexer.ml" # 259 "parser/wlexer.ml"
| 7 -> | 7 ->
# 100 "parser/wlexer.mll" # 107 "parser/wlexer.mll"
( let string_start = Lexing.lexeme_start lexbuf in ( let string_start = lexeme_start lexbuf in
string_start_pos := string_start; string_start_pos := string_start;
let double_quote = Lexing.lexeme_char lexbuf 0 = '"' in let double_quote = Lexing.lexeme_char lexbuf 0 = '"' in
string (Lexing.lexeme lexbuf) engine lexbuf; string (Lexing.lexeme lexbuf) engine lexbuf;
...@@ -260,50 +267,50 @@ let rec token engine lexbuf = ...@@ -260,50 +267,50 @@ let rec token engine lexbuf =
string_start - lexbuf.Lexing.lex_abs_pos; string_start - lexbuf.Lexing.lex_abs_pos;
(if double_quote then "STRING2" else "STRING1"), (if double_quote then "STRING2" else "STRING1"),
(get_stored_string()) ) (get_stored_string()) )
# 264 "parser/wlexer.ml" # 271 "parser/wlexer.ml"
| 8 -> | 8 ->
# 110 "parser/wlexer.mll" # 117 "parser/wlexer.mll"
( comment_start_pos := [Lexing.lexeme_start lexbuf]; ( comment_start_pos := [lexeme_start lexbuf];
in_comment := true; in_comment := true;
comment engine lexbuf; comment engine lexbuf;
in_comment := false; in_comment := false;
token engine lexbuf ) token engine lexbuf )
# 273 "parser/wlexer.ml" # 280 "parser/wlexer.ml"
| 9 -> | 9 ->
# 117 "parser/wlexer.mll" # 124 "parser/wlexer.mll"
( "EOI","" ) ( "EOI","" )
# 278 "parser/wlexer.ml" # 285 "parser/wlexer.ml"
| 10 -> | 10 ->
# 119 "parser/wlexer.mll" # 126 "parser/wlexer.mll"
( error ( error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character ((Lexing.lexeme lexbuf).[0])) ) (Illegal_character ((Lexing.lexeme lexbuf).[0])) )
# 285 "parser/wlexer.ml" # 292 "parser/wlexer.ml"
| _ -> failwith "lexing: empty token [token]" | _ -> failwith "lexing: empty token [token]"
and comment engine lexbuf = and comment engine lexbuf =
match engine __ocaml_lex_tables 27 lexbuf with match engine __ocaml_lex_tables 27 lexbuf with
| 0 -> | 0 ->
# 125 "parser/wlexer.mll" # 132 "parser/wlexer.mll"
( comment_start_pos := Lexing.lexeme_start lexbuf :: !comment_start_pos; ( comment_start_pos := lexeme_start lexbuf :: !comment_start_pos;
comment engine lexbuf; comment engine lexbuf;
) )
# 296 "parser/wlexer.ml" # 303 "parser/wlexer.ml"
| 1 -> | 1 ->
# 129 "parser/wlexer.mll" # 136 "parser/wlexer.mll"
( comment_start_pos := List.tl !comment_start_pos; ( comment_start_pos := List.tl !comment_start_pos;
if !comment_start_pos <> [] then comment engine lexbuf; if !comment_start_pos <> [] then comment engine lexbuf;
) )
# 303 "parser/wlexer.ml" # 310 "parser/wlexer.ml"
| 2 -> | 2 ->
# 133 "parser/wlexer.mll" # 140 "parser/wlexer.mll"
( string_start_pos := Lexing.lexeme_start lexbuf; ( string_start_pos := lexeme_start lexbuf;
Buffer.clear string_buff; Buffer.clear string_buff;
let ender = Lexing.lexeme lexbuf in let ender = Lexing.lexeme lexbuf in
(try string ender engine lexbuf (try string ender engine lexbuf
...@@ -312,93 +319,93 @@ and comment engine lexbuf = ...@@ -312,93 +319,93 @@ and comment engine lexbuf =
error st (st+2) Unterminated_string_in_comment); error st (st+2) Unterminated_string_in_comment);
Buffer.clear string_buff; Buffer.clear string_buff;
comment engine lexbuf ) comment engine lexbuf )
# 316 "parser/wlexer.ml" # 323 "parser/wlexer.ml"
| 3 -> | 3 ->
# 143 "parser/wlexer.mll" # 150 "parser/wlexer.mll"
( let st = List.hd !comment_start_pos in ( let st = List.hd !comment_start_pos in
error st (st+2) Unterminated_comment error st (st+2) Unterminated_comment
) )
# 323 "parser/wlexer.ml" # 330 "parser/wlexer.ml"
| 4 -> | 4 ->
# 147 "parser/wlexer.mll" # 154 "parser/wlexer.mll"
( comment engine lexbuf ) ( comment engine lexbuf )
# 328 "parser/wlexer.ml" # 335 "parser/wlexer.ml"
| _ -> failwith "lexing: empty token [comment]" | _ -> failwith "lexing: empty token [comment]"
and string ender engine lexbuf = and string ender engine lexbuf =
match engine __ocaml_lex_tables 33 lexbuf with match engine __ocaml_lex_tables 33 lexbuf with
| 0 -> | 0 ->
# 151 "parser/wlexer.mll" # 158 "parser/wlexer.mll"
( let c = Lexing.lexeme lexbuf in ( let c = Lexing.lexeme lexbuf in
if c = ender then () if c = ender then ()
else (store_char (Lexing.lexeme lexbuf); else (store_char (Lexing.lexeme lexbuf);
string ender engine lexbuf) ) string ender engine lexbuf) )
# 340 "parser/wlexer.ml" # 347 "parser/wlexer.ml"
| 1 -> | 1 ->
# 156 "parser/wlexer.mll" # 163 "parser/wlexer.mll"
( store_ascii (Lexing.lexeme_char lexbuf 1); ( store_ascii (Lexing.lexeme_char lexbuf 1);
string ender engine lexbuf ) string ender engine lexbuf )
# 346 "parser/wlexer.ml" # 353 "parser/wlexer.ml"
| 2 -> | 2 ->
# 159 "parser/wlexer.mll" # 166 "parser/wlexer.mll"
( let c = Lexing.lexeme_char lexbuf 1 in ( let c = Lexing.lexeme_char lexbuf 1 in
if c = 'x' if c = 'x'
then parse_hexa_char engine lexbuf then parse_hexa_char engine lexbuf
else store_special c; else store_special c;
string ender engine lexbuf ) string ender engine lexbuf )
# 355 "parser/wlexer.ml" # 362 "parser/wlexer.ml"
| 3 -> | 3 ->
# 165 "parser/wlexer.mll" # 172 "parser/wlexer.mll"
( store_code (decimal_char (Lexing.lexeme lexbuf)); ( store_code (decimal_char (Lexing.lexeme lexbuf));
string ender engine lexbuf ) string ender engine lexbuf )
# 361 "parser/wlexer.ml" # 368 "parser/wlexer.ml"
| 4 -> | 4 ->
# 168 "parser/wlexer.mll" # 175 "parser/wlexer.mll"
( error ( error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character '\\') ) (Illegal_character '\\') )
# 368 "parser/wlexer.ml" # 375 "parser/wlexer.ml"
| 5 -> | 5 ->
# 172 "parser/wlexer.mll" # 179 "parser/wlexer.mll"
( error !string_start_pos (!string_start_pos+1) Unterminated_string ) ( error !string_start_pos (!string_start_pos+1) Unterminated_string )
# 373 "parser/wlexer.ml" # 380 "parser/wlexer.ml"
| 6 -> | 6 ->
# 174 "parser/wlexer.mll" # 181 "parser/wlexer.mll"
( store_code (Char.code (Lexing.lexeme_char lexbuf 0)); ( store_code (Char.code (Lexing.lexeme_char lexbuf 0));
(* Adapt when source is UTF8 *) (* Adapt when source is UTF8 *)
string ender engine lexbuf ) string ender engine lexbuf )
# 380 "parser/wlexer.ml" # 387 "parser/wlexer.ml"
| _ -> failwith "lexing: empty token [string]" | _ -> failwith "lexing: empty token [string]"
and parse_hexa_char engine lexbuf = and parse_hexa_char engine lexbuf =
match engine __ocaml_lex_tables 37 lexbuf with match engine __ocaml_lex_tables 37 lexbuf with
| 0 -> | 0 ->
# 180 "parser/wlexer.mll" # 187 "parser/wlexer.mll"
( store_code (hexa_char (Lexing.lexeme lexbuf)) ) ( store_code (hexa_char (Lexing.lexeme lexbuf)) )
# 389 "parser/wlexer.ml" # 396 "parser/wlexer.ml"
| 1 -> | 1 ->
# 182 "parser/wlexer.mll" # 189 "parser/wlexer.mll"
( error ( error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character '\\') ) (Illegal_character '\\') )
# 396 "parser/wlexer.ml" # 403 "parser/wlexer.ml"
| _ -> failwith "lexing: empty token [parse_hexa_char]" | _ -> failwith "lexing: empty token [parse_hexa_char]"
;; ;;
# 188 "parser/wlexer.mll" # 195 "parser/wlexer.mll"
let delta_loc = ref 0 let delta_loc = ref 0
...@@ -410,10 +417,6 @@ and parse_hexa_char engine lexbuf = ...@@ -410,10 +417,6 @@ and parse_hexa_char engine lexbuf =
let last_tok = ref ("","") let last_tok = ref ("","")
let lexeme_start lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_start_pos
let lexeme_end lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_curr_pos
let lexer_func_of_wlex lexfun lexengine cs = let lexer_func_of_wlex lexfun lexengine cs =
let dl = !delta_loc in let dl = !delta_loc in
...@@ -593,4 +596,4 @@ and parse_hexa_char engine lexbuf = ...@@ -593,4 +596,4 @@ and parse_hexa_char engine lexbuf =
let latin1_engine = Lex_engines.engine_tiny_8bit table let latin1_engine = Lex_engines.engine_tiny_8bit table
# 597 "parser/wlexer.ml" # 600 "parser/wlexer.ml"
...@@ -15,6 +15,13 @@ classes ...@@ -15,6 +15,13 @@ classes
{ {
(* the new Lexing lib in OCaml 3.07 has a different handling of
locations. The following functions simulate the old behavior *)
let lexeme_start lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_start_pos
let lexeme_end lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_curr_pos
let keywords = Hashtbl.create 17 let keywords = Hashtbl.create 17
let in_comment = ref false let in_comment = ref false
...@@ -97,7 +104,7 @@ rule token = parse ...@@ -97,7 +104,7 @@ rule token = parse
{ "",Lexing.lexeme lexbuf } { "",Lexing.lexeme lexbuf }
| "#" ncname { "DIRECTIVE",Lexing.lexeme lexbuf } | "#" ncname { "DIRECTIVE",Lexing.lexeme lexbuf }
| '"' | "'" | '"' | "'"
{ let string_start = Lexing.lexeme_start lexbuf in { let string_start = lexeme_start lexbuf in
string_start_pos := string_start; string_start_pos := string_start;
let double_quote = Lexing.lexeme_char lexbuf 0 = '"' in let double_quote = Lexing.lexeme_char lexbuf 0 = '"' in
string (Lexing.lexeme lexbuf) engine lexbuf; string (Lexing.lexeme lexbuf) engine lexbuf;
...@@ -107,7 +114,7 @@ rule token = parse ...@@ -107,7 +114,7 @@ rule token = parse
(get_stored_string()) } (get_stored_string()) }
| "(*" | "(*"
{ comment_start_pos := [Lexing.lexeme_start lexbuf]; { comment_start_pos := [lexeme_start lexbuf];
in_comment := true; in_comment := true;
comment engine lexbuf; comment engine lexbuf;
in_comment := false; in_comment := false;
...@@ -117,12 +124,12 @@ rule token = parse ...@@ -117,12 +124,12 @@ rule token = parse
{ "EOI","" } { "EOI","" }
| _ | _
{ error { error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character ((Lexing.lexeme lexbuf).[0])) } (Illegal_character ((Lexing.lexeme lexbuf).[0])) }
and comment = parse and comment = parse
"(*" "(*"
{ comment_start_pos := Lexing.lexeme_start lexbuf :: !comment_start_pos; { comment_start_pos := lexeme_start lexbuf :: !comment_start_pos;
comment engine lexbuf; comment engine lexbuf;
} }
| "*)" | "*)"
...@@ -130,7 +137,7 @@ and comment = parse ...@@ -130,7 +137,7 @@ and comment = parse
if !comment_start_pos <> [] then comment engine lexbuf; if !comment_start_pos <> [] then comment engine lexbuf;
} }
| '"' | "'" | '"' | "'"
{ string_start_pos := Lexing.lexeme_start lexbuf; { string_start_pos := lexeme_start lexbuf;
Buffer.clear string_buff; Buffer.clear string_buff;
let ender = Lexing.lexeme lexbuf in let ender = Lexing.lexeme lexbuf in
(try string ender engine lexbuf (try string ender engine lexbuf
...@@ -166,7 +173,7 @@ and string ender = parse ...@@ -166,7 +173,7 @@ and string ender = parse
string ender engine lexbuf } string ender engine lexbuf }
| '\\' | '\\'
{ error { error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character '\\') } (Illegal_character '\\') }
| eof | eof
{ error !string_start_pos (!string_start_pos+1) Unterminated_string } { error !string_start_pos (!string_start_pos+1) Unterminated_string }
...@@ -180,7 +187,7 @@ and parse_hexa_char = parse ...@@ -180,7 +187,7 @@ and parse_hexa_char = parse
{ store_code (hexa_char (Lexing.lexeme lexbuf)) } { store_code (hexa_char (Lexing.lexeme lexbuf)) }
| _ | _
{ error { error
(Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf) (lexeme_start lexbuf) (lexeme_end lexbuf)
(Illegal_character '\\') } (Illegal_character '\\') }
...@@ -196,10 +203,6 @@ and parse_hexa_char = parse ...@@ -196,10 +203,6 @@ and parse_hexa_char = parse
let last_tok = ref ("","") let last_tok = ref ("","")
let lexeme_start lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_start_pos
let lexeme_end lexbuf =
lexbuf.Lexing.lex_abs_pos + lexbuf.Lexing.lex_curr_pos
let lexer_func_of_wlex lexfun lexengine cs = let lexer_func_of_wlex lexfun lexengine cs =
let dl = !delta_loc in let dl = !delta_loc in
......
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