{ module LogoLexer open System open LogoParser let lexeme = Microsoft.FSharp.Text.Lexing.LexBuffer<_>.LexemeString } let digit = ['0'-'9'] let alpha = ['a' - 'z'] let integer = digit+ let ident = alpha+ let whitesp = ' ' | '\t' let newline = '\n' | '\r' '\n' rule token = parse | whitesp { token lexbuf } | newline { lexbuf.EndPos <- lexbuf.EndPos.NextLine; token lexbuf } | "{" { LBRACE } | "}" { RBRACE } | "," { COMMA } | "+" { PLUS } | "-" { MINUS } | "*" { MUL } | "/" { DIV } | "(" { LPAREN } | ")" { RPAREN } | "left" { LTURN } | "right" { RTURN } | "forward" { FORWARD } | "pen" { PEN } | "color" { COLOR } | "if" { IF } | "repeat" { REPEAT } | "split" { SPLIT } | "define" { DEFINE } | ident { ID (lexeme lexbuf) } | integer { INT (Int32.Parse(lexeme lexbuf)) } | eof { EOF } | _ { failwithf "Unrecognized input '%s'" (lexeme lexbuf) }