From 262f161f42c4e59beec41c6f440336c38385426a Mon Sep 17 00:00:00 2001 From: Marc Coquand Date: Wed, 20 Dec 2023 20:46:00 -0600 Subject: Initial commit --- lib/lexer.mll | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/lexer.mll (limited to 'lib/lexer.mll') diff --git a/lib/lexer.mll b/lib/lexer.mll new file mode 100644 index 0000000..e8a7a73 --- /dev/null +++ b/lib/lexer.mll @@ -0,0 +1,27 @@ +{ +open Parser + +exception SyntaxError of string +} + +let digit = ['0'-'9'] +let frac = '.' digit* +let exp = ['e' 'E'] ['-' '+']? digit+ +let float = digit* frac? exp? +let white = [' ' '\t']+ +let newline = '\r' | '\n' | "\r\n" +let id = ['a'-'z' 'A'-'Z' '_']* + + +rule read = + parse + | white { read lexbuf } + | id { IDENTIFIER (Lexing.lexeme lexbuf) } + | "uuidv4" { UUIDV4 } + | "name" { NAME } + | ":" { COLON } + | "," { COMMA } + | "\n" { NEWLINE } + | "." { DOT } + | eof { EOF } + | _ as c { failwith (Printf.sprintf "unexpected character: %C" c) } -- cgit v1.2.3