-
Notifications
You must be signed in to change notification settings - Fork 0
/
url_lexer.mll
44 lines (41 loc) · 951 Bytes
/
url_lexer.mll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(*
* URL lexer for the program bd.
* Copyright 2023, Jing Huang.
* Licensed MIT.
*)
{
open Lexing
open Url_parser
}
let hdr = "https://www." | "https://" | "www." | ""
let srps = ".com" | ""
let ss = "ss" | "SS" | "sS" | "Ss"
let av = "av" | "AV" | "aV" | "Av"
let bv = "bv" | "BV" | "bV" | "Bv"
let ep = "ep" | "EP" | "eP" | "Ep"
let ident = ['a'-'z' 'A'-'Z' '0'-'9' '.' '-' '_']+
let white = [' ' '\t']+
let rest = ['a'-'z' 'A'-'Z' '0'-'9' '.' '-' '_' '/' '?' ':' '&' '=']*
rule token =
parse
| white { token lexbuf }
| ident { IDENT (Lexing.lexeme lexbuf) }
| hdr { SCHEME }
| srps { SRPL }
| rest { REST }
| "festival" { FVRFEST }
| "video" { FVRVIDO }
| "bangumi" { FVRBNGM }
| "play" { PLYFLG }
| "watchlater" { WCHLTR }
| ss { SSID }
| av { AVID }
| bv { BVID }
| ep { EPID }
| '/' { SLASH }
| '?' { QUESMARK }
| ':' { COLON }
| '&' { AMPERSAND }
| '#' { HASH }
| '=' { EQUAL }
| eof { EOF }