github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/optgen/cmd/langgen/ops_gen.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import ( 14 "fmt" 15 "io" 16 17 "github.com/cockroachdb/cockroach/pkg/sql/opt/optgen/lang" 18 ) 19 20 // generateOps generates the Operator type and enumeration for the Optgen 21 // AST nodes. 22 func generateOps(compiled *lang.CompiledExpr, w io.Writer) { 23 fmt.Fprintf(w, "type Operator int\n\n") 24 25 fmt.Fprintf(w, "const (\n") 26 fmt.Fprintf(w, " UnknownOp Operator = iota\n\n") 27 28 for _, define := range compiled.Defines { 29 fmt.Fprintf(w, " %sOp\n", define.Name) 30 } 31 32 fmt.Fprintf(w, ")\n\n") 33 }