summaryrefslogtreecommitdiff
path: root/Jennisys/AstUtils.fs
blob: 83104f5db9df81ce7cc24da7fc5fc77b00fb0b27 (plain)
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
module AstUtils

open Ast

let BinaryAnd (lhs: Expr) (rhs: Expr) = 
    match lhs, rhs with
    | IdLiteral("true"), _  -> rhs
    | IdLiteral("false"), _ -> IdLiteral("false")
    | _, IdLiteral("true")  -> lhs
    | _, IdLiteral("false") -> IdLiteral("false")
    | _, _                  -> BinaryExpr(30, "&&", lhs, rhs)

let BinaryOr (lhs: Expr) (rhs: Expr) = 
    match lhs, rhs with
    | IdLiteral("true"), _  -> IdLiteral("true")
    | IdLiteral("false"), _ -> rhs
    | _, IdLiteral("true")  -> IdLiteral("true")
    | _, IdLiteral("false") -> lhs
    | _, _                  -> BinaryExpr(30, "||", lhs, rhs)

let BinaryImplies lhs rhs = BinaryExpr(20, "==>", lhs, rhs)

let BinaryNeq lhs rhs = BinaryExpr(40, "!=", lhs, rhs)

let TrueLiteral = IdLiteral("true")
let FalseLiteral = IdLiteral("false")