aboutsummaryrefslogtreecommitdiff
path: root/lib/lexer.mll
blob: e0c54536e4928e73b657de8fda20d969ad73fccd (plain)
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
{
open Parser

exception SyntaxError of string
}

let digit = ['0'-'9']
let frac = '.' digit*
let exp = ['e' 'E'] ['-' '+']? digit+
let float = digit* frac? exp?
let int = digit+
let white = [' ' '\t']+
let newline = '\r' | '\n' | "\r\n"
let id = ['a'-'z' 'A'-'Z' '-']*
let newline = '\r' | '\n' | "\r\n"
let many_newline = newline+

rule read = 
  parse 
  | id { IDENTIFIER (Lexing.lexeme lexbuf) }
  | "_uuidv4" { UUIDV4 }
  | "_name" { NAME }
  | "_int" { INTSYMBOL } 
  | "(" { LBRACE }
  | ")" { RBRACE }
  | int { INT (Lexing.lexeme lexbuf |> int_of_string) }
  | white { read lexbuf } 
  | ":" { COLON }
  | ";" { SEMICOLON }
  | "," { COMMA }
  | many_newline { NEWLINE }
  | "." { DOT }
  | eof { EOF } 
	| _ as c { failwith (Printf.sprintf "unexpected character: %C" c) }