comparison lab0/lexer.mll @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 (* lab1/lexer.mll *)
2 (* Copyright (c) 2017 J. M. Spivey *)
3
4 {
5 open Parser
6 open Lexing
7 }
8
9 rule token =
10 parse
11 ['A'-'Z''a'-'z']['A'-'Z''a'-'z''0'-'9''_']* as s
12 { IDENT s }
13 | ['0'-'9']+("."['0'-'9']+)? as s
14 { NUMBER (float_of_string s) }
15 | "(" { OPEN }
16 | ")" { CLOSE }
17 | "=" { EQUAL }
18 | "+" { PLUS }
19 | "-" { MINUS }
20 | "*" { TIMES }
21 | "/" { DIVIDE }
22 | [' ''\t']+ { token lexbuf }
23 | "\n" { token lexbuf }
24 | _ { BADTOK }
25 | eof { EOF }
26