Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
module Lexer
|
||||
|
||||
open Parser // we need the terminal tokens from the Parser
|
||||
|
||||
let lexeme = Lexing.LexBuffer<_>.LexemeString
|
||||
}
|
||||
|
||||
let intNum = '-'? ['0'-'9']+
|
||||
let whitespace = ' ' | '\t'
|
||||
let newline = '\n' | '\r' '\n'
|
||||
|
||||
rule token = parse
|
||||
| intNum { INT (lexeme lexbuf |> int) }
|
||||
| '+' { PLUS }
|
||||
| '-' { MINUS }
|
||||
| '*' { TIMES }
|
||||
| '/' { DIVIDE }
|
||||
| '(' { LPAREN }
|
||||
| ')' { RPAREN }
|
||||
| whitespace { token lexbuf }
|
||||
| newline { lexbuf.EndPos <- lexbuf.EndPos.NextLine; token lexbuf }
|
||||
| eof { EOF }
|
||||
| _ { failwithf "unrecognized input: '%s'" <| lexeme lexbuf }
|
||||
Loading…
Add table
Add a link
Reference in a new issue