aboutsummaryrefslogtreecommitdiff
path: root/lib/Lexer.mll
diff options
context:
space:
mode:
authorMalte Voos <git@mal.tc>2024-02-16 00:43:04 +0100
committerMalte Voos <git@mal.tc>2024-02-16 00:43:04 +0100
commit06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2 (patch)
treec558e81d84fd12ef66e99c558e5b7dd1322e5c03 /lib/Lexer.mll
parent2bc6cae2458ba5f9573985791536618a00cbed8a (diff)
downloadtoytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.tar.gz
toytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.zip
basic lexer and parser
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 }