-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plc.sml
44 lines (41 loc) · 1.61 KB
/
Plc.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(* Plc interpreter main file *)
CM.make("$/basis.cm");
CM.make("$/ml-yacc-lib.cm");
use "Environ.sml";
use "Absyn.sml";
use "PlcChecker.sml";
use "PlcInterp.sml";
use "PlcParserAux.sml";
use "PlcParser.yacc.sig";
use "PlcParser.yacc.sml";
use "PlcLexer.lex.sml";
use "Parse.sml";
use "testParserCases.sml";
open PlcFrontEnd;
fun run (e:expr) =
let
val TypeCheck = teval(e,[])
val Evaluation = eval(e,[])
in
(val2string Evaluation) ^ " : " ^ (type2string TypeCheck)
end
handle SymbolNotFound => "Undefined Symbol detected."
| EmptySeq => "Empty sequence as input."
| UnknownType => "Unknown Type."
| NotEqTypes => "Types not Equal."
| WrongRetType => "Wrong Return Type."
| DiffBrTypes => "Conditional branches have different type."
| IfCondNotBool => "If conditional is not Boolean."
| NoMatchResults => "No match results."
| MatchResTypeDiff => "Match result with wrong type."
| MatchCondTypesDiff => "Match is with different type."
| CallTypeMisM => "Function call with wrong Type."
| NotFunc => "Not a function."
| ListOutOfRange => "Trying to access invalid value from List."
| OpNonList => "Expression is not a List."
| HDEmptySeq => "Head from empty sequence is empty."
| TLEmptySeq => "Tail from empty sequence is empty"
| ValueNotFoundInMatch => "Value not found."
| NotAFunc => "Value is not a function."
| Impossible => "Operation can't be executed."
| _ => "Unexpected exeption."