From 06d52c8ba30b1bd6e1174ebffbd6cc5ba668ecc2 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Fri, 16 Feb 2024 00:43:04 +0100 Subject: basic lexer and parser --- lib/Lexer.mll | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 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..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 } -- cgit 1.4.1