~ubuntu-branches/ubuntu/lucid/camomile/lucid

« back to all changes in this revision

Viewing changes to toolslib/colLexer.mll

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Le Gall
  • Date: 2005-12-03 01:18:55 UTC
  • Revision ID: james.westby@ubuntu.com-20051203011855-qzvwlld1xyqnl62t
Tags: upstream-0.6.3
ImportĀ upstreamĀ versionĀ 0.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(* $Id: colLexer.mll,v 1.6 2003/12/19 17:24:34 yori Exp $ *)
 
2
(* Copyright 2003 Yamagata Yoriyuki *)
 
3
 
 
4
{
 
5
open ColParser
 
6
let blank = Str.regexp "[ \t\n]+"
 
7
}
 
8
 
 
9
let utf8_char = 
 
10
  ['\000'-'\127'] 
 
11
| ['\194'-'\223']['\128'-'\191']
 
12
| ['\224'-'\239']['\128'-'\191']['\128'-'\191']
 
13
| ['\240'-'\247']['\128'-'\191']['\128'-'\191']['\128'-'\191']
 
14
| ['\248'-'\251']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']
 
15
| ['\252'-'\253']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']['\128'-'\191']
 
16
 
 
17
rule token = parse
 
18
  eof {(* print_endline "EOF";*) EOF}
 
19
| '\'' utf8_char '\'' {
 
20
  let s = Lexing.lexeme lexbuf in
 
21
  let u = UTF8.look s 0 in
 
22
(*  Printf.printf "UCHAR1 \\u%02x\n" (int_of_uchar u); *)
 
23
  UCHAR u}
 
24
| '[' [^']']* ']' {(* print_endline "OPTION"; *)
 
25
  let s = Lexing.lexeme lexbuf in
 
26
  let option = String.sub s 1 (String.length s - 2) in
 
27
  OPTION (Str.split blank option)}
 
28
| '<' {(* print_endline "PRIMARY"; *) PRIMARY}
 
29
| "<<" {(* print_endline "SECONDARY";*) SECONDARY}
 
30
| ';' {(*print_endline "SECONDARY";*) SECONDARY}
 
31
| "<<<" {(*print_endline "TERTIARY";*) TERTIARY}
 
32
| ',' {(*print_endline "TERTIARY";*) TERTIARY}
 
33
| '=' {(*print_endline "EQ";*) EQ}
 
34
| '&' {(*print_endline "RESET";*) RESET}
 
35
| '/' {(*print_endline "EXPAND";*) EXPAND}
 
36
| '|' {(*print_endline "PREFIX";*) PREFIX}
 
37
| [' ' '\t' '\n'] {token lexbuf}
 
38
| utf8_char {
 
39
  let s = Lexing.lexeme lexbuf in
 
40
  let u = UTF8.look s 0 in
 
41
(*  Printf.printf "UCHAR2 \\u%04x\n" (int_of_uchar u);*)
 
42
  UCHAR u}
 
43
 
 
44