aboutsummaryrefslogtreecommitdiff
path: root/lib/lexer.mll
diff options
context:
space:
mode:
authorMarc Coquand <marc@mccd.space>2023-12-20 20:46:00 -0600
committerMarc Coquand <marc@mccd.space>2023-12-25 18:22:59 -0600
commit262f161f42c4e59beec41c6f440336c38385426a (patch)
tree6491c9b661a0b5a14c9a30ecf25e036f8762239d /lib/lexer.mll
parentcc783c157f31e7e713c8b83be67449b1859dac27 (diff)
downloadfixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.gz
fixgen-262f161f42c4e59beec41c6f440336c38385426a.tar.bz2
fixgen-262f161f42c4e59beec41c6f440336c38385426a.zip
Initial commit
Diffstat (limited to 'lib/lexer.mll')
-rw-r--r--lib/lexer.mll27
1 files changed, 27 insertions, 0 deletions
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) }