module org/webdsl/dsl/languages/action/if-exp

imports
libstrategolib
libwebdsl-front

rules // if in expression: if(e) e1 else e2

constraint-error-action :
IfExp(e, eif, eelse) -> <add-error(|["expression ", <pp-webdsl> e, " should be of type Bool"])>
where not(SimpleSort("Bool") := <type-of> e)
; <type-of> e // don't report when sub-expression was already wrong

constraint-error-action :
IfExp(_, ei, ee) -> <add-error(|["type ",<pp-type> te," of expression ", <pp-webdsl> ee, " is not compatible with type ",<pp-type> ti," of expression ",<pp-webdsl> ei])>
where ti := <type-of> ei
; te := <type-of> ee
; not(<type-compatible> (ti,te))

eq-type-of-action :
IfExp(_, ei, _) -> t
where t := <type-of> ei