Skip to content

Commit

Permalink
htmlStream: parse <title> in “raw” mode
Browse files Browse the repository at this point in the history
Cf.
<https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead>

`make -B gen_ragel` seems to also modify the locations
in `devkit_ragel.ml`; I use the following:

```
 $ ragel --version
Ragel State Machine Compiler version 6.8+20190930 Feb 2013
Copyright (c) 2001-2009 by Adrian Thurston
```
  • Loading branch information
smondet authored and rr0gi committed Nov 12, 2024
1 parent 6e87d8d commit 1f3f7ed
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 73 deletions.
34 changes: 17 additions & 17 deletions devkit_ragel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# 1 "devkit_ragel.ml.rl"


# 6 "devkit_ragel.ml"
# 4 "devkit_ragel.ml"
let _ipv4_trans_keys : int array = Array.concat [ [|
0; 0; 48; 57; 46; 57; 48; 57; 46; 57; 48; 57; 46; 57; 48; 57;
46; 57; 46; 46; 46; 57; 46; 46; 46; 57; 46; 46; 48; 57; 48; 57;
Expand Down Expand Up @@ -85,14 +85,14 @@ let parse_ipv4 data =
ip := Int32.logor (Int32.shift_left !ip 8) (Int32.of_int !n)
in

# 89 "devkit_ragel.ml"
# 85 "devkit_ragel.ml"
begin
cs.contents <- ipv4_start;
end;

# 20 "devkit_ragel.ml.rl"

# 96 "devkit_ragel.ml"
# 90 "devkit_ragel.ml"
begin
let state = { keys = 0; trans = 0; } in
let rec do_start () =
Expand Down Expand Up @@ -145,7 +145,7 @@ and do_eof_trans () =
# 4 "devkit_ragel.ml.rl"
begin n := 10 * !n + (Char.code data.[p.contents] - Char.code '0') end;
()
# 149 "devkit_ragel.ml"
# 143 "devkit_ragel.ml"
| _ -> ()
with Goto_again_ipv4 -> () end;

Expand All @@ -166,7 +166,7 @@ and do_test_eof () =
# 5 "devkit_ragel.ml.rl"
begin set () end;
()
# 170 "devkit_ragel.ml"
# 164 "devkit_ragel.ml"
| _ -> ()
end
with Goto_again_ipv4 -> do_again ()
Expand All @@ -184,15 +184,15 @@ let is_ipv4_slow data =
let n = ref 0 in
let set () = if !n > 255 then raise Not_found in

# 188 "devkit_ragel.ml"
# 180 "devkit_ragel.ml"
begin
cs.contents <- ipv4_start;
end;

# 28 "devkit_ragel.ml.rl"
try

# 196 "devkit_ragel.ml"
# 186 "devkit_ragel.ml"
begin
let state = { keys = 0; trans = 0; } in
let rec do_start () =
Expand Down Expand Up @@ -245,7 +245,7 @@ and do_eof_trans () =
# 4 "devkit_ragel.ml.rl"
begin n := 10 * !n + (Char.code data.[p.contents] - Char.code '0') end;
()
# 249 "devkit_ragel.ml"
# 239 "devkit_ragel.ml"
| _ -> ()
with Goto_again_ipv4 -> () end;

Expand All @@ -266,7 +266,7 @@ and do_test_eof () =
# 5 "devkit_ragel.ml.rl"
begin set () end;
()
# 270 "devkit_ragel.ml"
# 260 "devkit_ragel.ml"
| _ -> ()
end
with Goto_again_ipv4 -> do_again ()
Expand All @@ -281,7 +281,7 @@ and do_test_eof () =
with Not_found -> false


# 285 "devkit_ragel.ml"
# 273 "devkit_ragel.ml"
let _is_ipv4_trans_keys : int array = Array.concat [ [|
0; 0; 48; 57; 46; 57; 48; 57; 46; 57; 48; 57; 46; 57; 48; 57;
46; 57; 46; 46; 46; 57; 46; 53; 46; 57; 46; 46; 46; 57; 46; 53;
Expand Down Expand Up @@ -359,14 +359,14 @@ exception Goto_eof_trans_is_ipv4
let is_ipv4 data =
let cs = ref 0 and p = ref 0 and pe = ref (String.length data) in

# 363 "devkit_ragel.ml"
# 349 "devkit_ragel.ml"
begin
cs.contents <- is_ipv4_start;
end;

# 43 "devkit_ragel.ml.rl"

# 370 "devkit_ragel.ml"
# 354 "devkit_ragel.ml"
begin
let state = { keys = 0; trans = 0; } in
let rec do_start () =
Expand Down Expand Up @@ -412,7 +412,7 @@ and do_test_eof () =
!cs >= is_ipv4_first_final


# 416 "devkit_ragel.ml"
# 398 "devkit_ragel.ml"
let _compact_duration_trans_keys : int array = Array.concat [ [|
0; 0; 115; 115; 48; 110; 115; 115; 46; 110; 48; 109; 48; 109; 48; 109;
109; 109; 48; 57; 46; 115; 48; 115; 48; 115; 48; 115; 109; 115; 48; 57;
Expand Down Expand Up @@ -596,14 +596,14 @@ let parse_compact_duration data =
let n = ref 0 and f = ref 0. and fna = ref 0 and fn = ref 0 in
let t = ref 0 in

# 600 "devkit_ragel.ml"
# 580 "devkit_ragel.ml"
begin
cs.contents <- compact_duration_start;
end;

# 69 "devkit_ragel.ml.rl"

# 607 "devkit_ragel.ml"
# 585 "devkit_ragel.ml"
begin
let state = { keys = 0; trans = 0; } in
let rec do_start () =
Expand Down Expand Up @@ -698,7 +698,7 @@ and do_eof_trans () =
# 51 "devkit_ragel.ml.rl"
begin n := 10 * !n + (Char.code data.[p.contents] - Char.code '0') end;
()
# 702 "devkit_ragel.ml"
# 680 "devkit_ragel.ml"
| _ -> ()
with Goto_again_compact_duration -> () end;

Expand Down Expand Up @@ -745,7 +745,7 @@ and do_test_eof () =
# 48 "devkit_ragel.ml.rl"
begin f := !f +. (float(!fn) /. (10. ** float(!fna))); t := !t + !n; fn := 0; fna := 0; end;
()
# 749 "devkit_ragel.ml"
# 727 "devkit_ragel.ml"
| _ -> ()
end
with Goto_again_compact_duration -> do_again ()
Expand Down
Loading

0 comments on commit 1f3f7ed

Please sign in to comment.