File: colLexer.mll

package info (click to toggle)
camomile 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 18,680 kB
  • ctags: 2,269
  • sloc: ml: 11,806; makefile: 336; xml: 224; sh: 75
file content (44 lines) | stat: -rw-r--r-- 1,474 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(* $Id: colLexer.mll,v 1.6 2003/12/19 17:24:34 yori Exp $ *)
(* Copyright 2003 Yamagata Yoriyuki *)

{
open ColParser
let blank = Str.regexp "[ \t\n]+"
}

let utf8_char = 
  ['\000'-'\127'] 
| ['\194'-'\223']['\128'-'\191']
| ['\224'-'\239']['\128'-'\191']['\128'-'\191']
| ['\240'-'\247']['\128'-'\191']['\128'-'\191']['\128'-'\191']
| ['\248'-'\251']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']
| ['\252'-'\253']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']

rule token = parse
  eof {(* print_endline "EOF";*) EOF}
| '\'' utf8_char '\'' {
  let s = Lexing.lexeme lexbuf in
  let u = UTF8.look s 0 in
(*  Printf.printf "UCHAR1 \\u%02x\n" (int_of_uchar u); *)
  UCHAR u}
| '[' [^']']* ']' {(* print_endline "OPTION"; *)
  let s = Lexing.lexeme lexbuf in
  let option = String.sub s 1 (String.length s - 2) in
  OPTION (Str.split blank option)}
| '<' {(* print_endline "PRIMARY"; *) PRIMARY}
| "<<" {(* print_endline "SECONDARY";*) SECONDARY}
| ';' {(*print_endline "SECONDARY";*) SECONDARY}
| "<<<" {(*print_endline "TERTIARY";*) TERTIARY}
| ',' {(*print_endline "TERTIARY";*) TERTIARY}
| '=' {(*print_endline "EQ";*) EQ}
| '&' {(*print_endline "RESET";*) RESET}
| '/' {(*print_endline "EXPAND";*) EXPAND}
| '|' {(*print_endline "PREFIX";*) PREFIX}
| [' ' '\t' '\n'] {token lexbuf}
| utf8_char {
  let s = Lexing.lexeme lexbuf in
  let u = UTF8.look s 0 in
(*  Printf.printf "UCHAR2 \\u%04x\n" (int_of_uchar u);*)
  UCHAR u}