ocaml

let buf = Lexing. from_channel stdin in
let f = lex float buf in
print endline f
You should lex floats according to the following (after
A floating constant consists of an integer part, a decimal point, a fraction part, an e or an E, and an optionally signed integer exponent. The integer and fraction parts both consist of a sequence of digits. Either the integer part, or the fraction part (not both) may be missing; either the decimal point or the e/E and the exponent (not both) may be missing.
Hint: make sure your regular expression accepts floating constants such as 1. 0.5-15 .3E +3 .2 le5 3.5E-4 but not integer constants such as 42

1. 20pt Extend the three-slide “calculator” example shown in the OCaml slides (the source is also available on the class website to accept variables named with identifiers consisting of lowercase letters, assignment to those vari-ables, and sequencing using the “” operator. For example,
foo = 3; bar = baz = 6; foo * bar + baz
should print “24”
Use a string-to-integer Map to track variable variables.
Add tokens to the parser and scanner for representing as-signment, sequencing, and variable names.
The ocamllex rule for the variable names, which converts the letters a-z into the corresponding literals, is [‘a’-‘z’]+ as id { VARIABLE (id) }
The new ast. mli file is
type operator = Add Sub | Mul Div
type expr =
Binop of expr * operator * expr
Lit of int
Seq of expr * expr
Asn of string * expr
Var of string
Make sure your code compiles without warnings
2. 10pt Write a regular expression for lexing floating point constants in a file called scanner.mll. Your tokenizing rule should be called lex float. Your code should build without warnings when ocamlbuild scanner.native is run from the terminal. Your executable should read from stdin and print the successfully lexed pattern to stdout. In order to do so, include the following code at the end of scanner. mli.