about summary refs log tree commit diff
path: root/lib/Lexer.mll
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Lexer.mll')
-rw-r--r--lib/Lexer.mll31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Lexer.mll b/lib/Lexer.mll
new file mode 100644
index 0000000..55a22c2
--- /dev/null
+++ b/lib/Lexer.mll
@@ -0,0 +1,31 @@
+{
+open Parser
+}
+
+let whitespace = [' ' '\t' '\r' '\n']+
+let letter = ['a'-'z' 'A'-'Z']
+let ident = letter+
+
+rule lex =
+  parse
+  | whitespace { lex lexbuf }
+  | "(" { LPR }
+  | ")" { RPR }
+  | "[" { LBR }
+  | "]" { RBR }
+  | "->" { ARROW }
+  | "*" { ASTERISK }
+  | "\\" { BACKSLASH }
+  | ":" { COLON }
+  | "," { COMMA }
+  | "." { DOT }
+  | "=>" { FATARROW }
+  | "bool" { BOOL }
+  | "true" { TRUE }
+  | "false" { FALSE }
+  | "bool-elim" { BOOL_ELIM }
+  | "at" { AT }
+  | "fst" { FST }
+  | "snd" { SND }
+  | ident { IDENT (Lexing.lexeme lexbuf) }
+  | eof { EOF }