lexer.mll 1020 Bytes
Newer Older
1
2
{
  open Parser
3
  exception Unexpected_char of string
4
5
}

6
let id = [ 'a'-'z' '_' '0'-'9' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']*
7

8
rule token = parse
Raphaël Cauderlier's avatar
Raphaël Cauderlier committed
9
    | [ ' ' '\t' ] { token lexbuf }
10
    | '\n' { token lexbuf }
11
12
13
14
    (* The several meanings of "." are disambiguated at lexing *)
    | '.' (id as s) ' '* "<=" { UPDATE (s) }
    | '.' (id as s) ' '* ":=" { FUPD(s) }
    | '.' (id as s) { SELECT (s) }
15
16
17
18
19
20
21
22
    | '[' { LBRACK }
    | ']' { RBRACK }
    | ':' { COLUMN }
    | ';' { SEMICOLUMN }
    | '(' { LPAR }
    | ')' { RPAR }
    | "ς" { SIGMA }
    | '=' { EQUAL }
Raphaël Cauderlier's avatar
Raphaël Cauderlier committed
23
    | "::=" { DEF }
24
25
26
27
    | '.' { DOT }
    | "->" { ARR }
    | "λ" { LAMBDA }
    | "type" { TYPE (Parsing.rhs_start_pos 1) }
28
    | "let" { VAR (Parsing.rhs_start_pos 1) }
29
30
    | "check" { CHECK (Parsing.rhs_start_pos 1) }
    | "norm" { NORM (Parsing.rhs_start_pos 1) }
31
    | id as s { ID (s) }
32
    | [ 'A'-'Z' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']* as s { CID (s) }
33
    | _ as c { raise (Unexpected_char (Printf.sprintf"'%c'" c)) }
34
    | eof { raise End_of_file }