lexer.mll 981 Bytes
Newer Older
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
{
  open Parser
  exception Unexpected_char of char
}

rule token = parse
    | [ ' ' '\t' ] as c
        { Format.eprintf "ignore '%c'@\n" c; token lexbuf }
    | '\n' { token lexbuf }
    | '.'([ 'a'-'z' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']* as s)"<=" { UPDATE (s) }
    | '.'([ 'a'-'z' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']* as s) { SELECT (s) }
    | '[' { LBRACK }
    | ']' { RBRACK }
    | ':' { COLUMN }
    | ';' { SEMICOLUMN }
    | '(' { LPAR }
    | ')' { RPAR }
    | "ς" { SIGMA }
    | '=' { EQUAL }
    | ":=" { DEF }
    | '.' { DOT }
    | "->" { ARR }
    | "λ" { LAMBDA }
    | "type" { TYPE (Parsing.rhs_start_pos 1) }
    | "var" { VAR (Parsing.rhs_start_pos 1) }
    | "check" { CHECK (Parsing.rhs_start_pos 1) }
    | "norm" { NORM (Parsing.rhs_start_pos 1) }
    | [ 'a'-'z' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']* as s { ID (s) }
    | [ 'A'-'Z' ] ['a'-'z' 'A'-'Z' '_' '0'-'9']* as s { CID (s) }
    | _ as c { raise (Unexpected_char c) }
    | eof { raise End_of_file }