sperretta / HLP

0 stars 0 forks source link

Execution Engine: Set #26

Closed Matthewar closed 7 years ago

Matthewar commented 7 years ago

Child of #7 (Put general queries about execution engine there) Branch: feature/execution-engine/set

Sets the value of a variable to the expression, which will need to be evaluated (will likely make another method for executing this function). Type check (#24) must be done between variable type and type of expression result.

Matthewar commented 7 years ago

For operations to be performed on the boxdata type they need to be added

    type boxData = | String of Option<string>  // To be extended when the wanted data types have been decided
                   | Int of Option<int> 
                   | Float of Option<float>                
                   | Byte of Option<byte>     
                   | Bool of Option<bool>
                   static member (+) (x,y) =
                        match x,y with
                        | Int(Some(a)),Int(Some(b)) -> Result(Int(Some(a+b)))
                        | Float(Some(a)),Float(Some(b)) -> Result(Float(Some(a+b)))
                        | Byte(Some(a)),Byte(Some(b)) -> Result(Byte(Some(a+b)))
                        | _ -> Error(sprintf "Types do not match %A %A" x y)

I need something like this for subtract, multiply and divide too please. If you want, you can add more precise errors (e.g. for bools/strings can't do maths, etc.)

Matthewar commented 7 years ago

Merged with execution engine parser.