Esempio n. 1
0
func translateBinaryExpr(node *ast.BinaryExprNode) core.CoreExpr {
	left := translateExpr(node.Left)
	right := translateExpr(node.Right)
	var oper string
	switch node.Op {
	case token.ADD:
		oper = "+"
	case token.SUB:
		oper = "-"
	case token.MUL:
		oper = "*"
	case token.QUO:
		oper = "/"
	case token.REM:
		oper = "%"
	case token.EQL:
		oper = "=="
	case token.LSS:
		oper = "<"
	case token.GTR:
		oper = ">"
	default:
		oper = ""
	}
	fmt.Println("BinaryExpr: ", left, oper, right)
	return core.EAp{core.EAp{core.EVar(oper), left}, right} // TODO: Incomplete fn require support of prelude in core-ast
}
Esempio n. 2
0
func translateVariable(node *ast.VariableNode) core.CoreExpr {
	return core.EVar(node.Ident)
}