File: complement.ml

package info (click to toggle)
ocaml-sedlex 3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 792 kB
  • sloc: ml: 7,866; makefile: 24; sh: 9
file content (20 lines) | stat: -rw-r--r-- 453 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let ucase = [%sedlex.regexp? 'A' .. 'Z']
let lcase = [%sedlex.regexp? 'a' .. 'z']

let rec token buf =
  match%sedlex buf with
    | lcase ->
        print_char 'L';
        token buf
    | Compl (ucase | lcase) ->
        print_char '?';
        token buf
    | ucase ->
        print_char 'U';
        token buf
    | eof -> print_endline "."
    | _ -> assert false

let () =
  let lexbuf = Sedlexing.Latin1.from_string "Abc::DefG" in
  token lexbuf