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

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