annotate 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
rev   line source
mike@0 1 (* lab1/lexer.mll *)
mike@0 2 (* Copyright (c) 2017 J. M. Spivey *)
mike@0 3
mike@0 4 {
mike@0 5 open Parser
mike@0 6 open Lexing
mike@0 7 }
mike@0 8
mike@0 9 rule token =
mike@0 10 parse
mike@0 11 ['A'-'Z''a'-'z']['A'-'Z''a'-'z''0'-'9''_']* as s
mike@0 12 { IDENT s }
mike@0 13 | ['0'-'9']+("."['0'-'9']+)? as s
mike@0 14 { NUMBER (float_of_string s) }
mike@0 15 | "(" { OPEN }
mike@0 16 | ")" { CLOSE }
mike@0 17 | "=" { EQUAL }
mike@0 18 | "+" { PLUS }
mike@0 19 | "-" { MINUS }
mike@0 20 | "*" { TIMES }
mike@0 21 | "/" { DIVIDE }
mike@0 22 | [' ''\t']+ { token lexbuf }
mike@0 23 | "\n" { token lexbuf }
mike@0 24 | _ { BADTOK }
mike@0 25 | eof { EOF }
mike@0 26