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...


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.

In[]:

//

// 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
Jun 28, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here