Write a lexical analyzer which uses above types to generate sequence of tokens from the input string. You will tokenize strings composed of integer numbers and arithmetic operations. Let's define these tokens.
//
// RUN THIS CELL BEFORE CONTINUE
type TOKEN =
| INT of int // integer number
| ADD_OP // addition operation
| SUB_OP // subtraction operation
| MUL_OP // multiplication operation
| UNKNOWN // uknown symbol
| EOF // end of input
// helper functions
let charsToInt (cs:char list) :int =
List.fold (fun a c -> a + string c) "" cs |> int
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here