{ module Lexer open System open Parser open Microsoft.FSharp.Text.Lexing } // These are some regular expression definitions let digit = ['0'-'9'] let nondigit = [ 'a'-'z' 'A'-'Z' '_' ] let idchar = (nondigit | digit) let whitespace = [' ' '\t' ] let newline = ('\n' | '\r' '\n') rule tokenize = parse | whitespace { tokenize lexbuf } | newline { tokenize lexbuf } // operators | "==" { EQ } | "!=" { NEQ } | "+" { PLUS } | "-" { MINUS } | "*" { STAR } | "<" { LESS } | "<=" { ATMOST } | "and" { AND } | "or" { OR } | "not" { NOT } | "old" { OLD } | "." { DOT } // misc | "(" { LPAREN } | ")" { RPAREN } | ";" { SEMI } | ":=" { ASSIGN } // keywords | "procedure" { PROCEDURE } | "requires" { REQUIRES } | "ensures" { ENSURES } | "do" { DO } | "end" { END } | "new" { NEW } | "if" { IF } | "then" { THEN } | "else" { ELSE } | "while" { WHILE } | "invariant" { INVARIANT } | "call" { CALL } | "assert" { ASSERT } // literals | ['-']?digit+ { INT32 (Int32.Parse(LexBuffer.LexemeString lexbuf)) } | "null" { NULL } // identifiers | idchar+ { ID (LexBuffer.LexemeString lexbuf) } // EOF | eof { EOF }