diff options
author | Malte Voos <git@mal.tc> | 2024-02-16 00:43:04 +0100 |
---|---|---|
committer | Malte Voos <git@mal.tc> | 2024-02-16 00:43:04 +0100 |
commit | 06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2 (patch) | |
tree | c558e81d84fd12ef66e99c558e5b7dd1322e5c03 /lib/Lexer.mll | |
parent | 2bc6cae2458ba5f9573985791536618a00cbed8a (diff) | |
download | toytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.tar.gz toytt-06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2.zip |
basic lexer and parser
Diffstat (limited to 'lib/Lexer.mll')
-rw-r--r-- | lib/Lexer.mll | 31 |
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 } |