module Semantic: sig
.. end
Contains all the functions to perform a small semantic analisys, which means only type checking :)
To do this has been introduced the "Semantic Type" which simplify the check
Contains all the functions to perform a small semantic analisys, which means only type checking :)
To do this has been introduced the "Semantic Type" which simplify the check
val getType : Intermediate.element -> Intermediate.sType
Recovers the semantic type from an offset
Returns The semantic type of t
t
: The element from which recover the type
val checkAexp : Syntaxtree.aexp ->
Intermediate.dec_table -> Intermediate.proc_table -> Intermediate.sType
Checks the Semantic types of the arithmetical expressions
Returns The semantic type of ex
ex
: The arithmetical expression to check
val checkParTypes : Syntaxtree.dec list ->
Syntaxtree.aexp list ->
Intermediate.dec_table -> Intermediate.proc_table -> bool
Checks the semantic type of a list of parameters
Returns True if the formal parameters types match with the actual parameters type, False otherwise
plist
: The list of formal parameters
el
: The list of actual parameters
dect
: The declarations table
proct
: The procedures table
val checkBool : Syntaxtree.bexp ->
Intermediate.dec_table -> Intermediate.proc_table -> Intermediate.sType
Checks the semantic type of boolean operations (compare is only allowed betrween int and int or float and float,
not mixed operations)
Returns The sematic type of b
b
: The boolean operation to check
dect
: The declarations table
proct
: The procedures table
val checkLexp : Syntaxtree.lexp ->
Intermediate.dec_table -> Intermediate.proc_table -> Intermediate.sType
Checks the semantic type of left expression
Returns The semantic type of l
l
: The left expression to check
dect
: The declarations table
val cmdsemantic : Syntaxtree.cmd -> Intermediate.dec_table -> Intermediate.proc_table -> bool
Checks the semantic type of commands
Returns True of the command is well formed (type checking is good), Flase otherwise
c
: The command to check
dect
: The declarations table