{

module Lexer

open FSharp.Text.Lexing
open System
open Parser

let newline (lexbuf: LexBuffer<_>) =
    lexbuf.StartPos <- lexbuf.StartPos.NextLine

let lexem (lexbuf: LexBuffer<_>) = LexBuffer<_>.LexemeString lexbuf

}

// Regular expressions
let whitespace = [ ' ' '\t' ]
let newline = ('\n' | '\r' '\n')

rule read =
    parse
    | whitespace     { read lexbuf }
    | newline        { Parser.NEWLINE }
    | ['T' 't']      { Parser.T }
    | ['F' 'f']      { Parser.F }
    | '='            { Parser.ASSIGN }
    | '&'            { Parser.AND }
    | "=>"           { Parser.IMPLIES }
    | "|-"           { Parser.INFER }
    | '('            { Parser.LPAR }
    | ')'            { Parser.RPAR }
    | ['a'-'z']+     { ID( lexem lexbuf ) }
    | _              { failwith ("ParseError: no rule for lexem " + lexem lexbuf) }
    | eof            { Parser.EOF }
