e0/lib/lexer.mll

23 lines
494 B
OCaml
Raw Normal View History

2022-03-08 06:16:27 +00:00
{ open Parser }
rule f = parse
2022-03-08 08:52:20 +00:00
| '\n' { Lexing.new_line lexbuf; f lexbuf }
| [' ' '\t'] { f lexbuf }
| "extern" { KWD_EXTERN }
2022-03-08 06:16:27 +00:00
| "fn" { KWD_FN }
2022-03-08 08:52:20 +00:00
| "return" { KWD_RETURN }
2022-03-08 08:52:20 +00:00
| "(" { PUNCT_LPAREN }
| ")" { PUNCT_RPAREN }
| "->" { PUNCT_RARROW }
| ":" { PUNCT_COLON }
| ";" { PUNCT_SEMI }
| "{" { PUNCT_LBRACE }
| "}" { PUNCT_RBRACE }
2022-03-08 08:52:20 +00:00
| "-" ['0'-'9']+ as i { LIT_NEG_INT (- (int_of_string i)) }
| ['0'-'9']+ as i { LIT_INT (int_of_string i) }
| ['a'-'z' 'A'-'Z']* as i { IDENT i }
| eof { EOF }