Esempio n. 1
0
File: eval.go Progetto: 8l/gsp
func EvalExpr(node parser.Node) ast.Expr {
	switch t := node.Type(); t {
	case parser.NodeCall:
		node := node.(*parser.CallNode)
		return evalFuncCall(node)

	case parser.NodeVector:
		node := node.(*parser.VectorNode)
		return makeVector(anyType, EvalExprs(node.Nodes))

	case parser.NodeNumber:
		node := node.(*parser.NumberNode)
		return makeBasicLit(node.NumberType, node.Value)

	case parser.NodeString:
		node := node.(*parser.StringNode)
		return makeBasicLit(token.STRING, node.Value)

	case parser.NodeIdent:
		node := node.(*parser.IdentNode)
		return makeIdomaticSelector(node.Ident)

	default:
		println(t)
		panic("not implemented yet!")
	}
}
Esempio n. 2
0
File: generator.go Progetto: 8l/gsp
func isNSDecl(node parser.Node) bool {
	if node.Type() != parser.NodeCall {
		return false
	}

	call := node.(*parser.CallNode)
	if call.Callee.(*parser.IdentNode).Ident != "ns" {
		return false
	}

	if len(call.Args) < 1 {
		return false
	}

	return true
}