forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
strings.go
39 lines (35 loc) · 1.22 KB
/
strings.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2016 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.
package ast
import (
"reflect"
"strings"
)
// TypeName returns a human readable name for the AST element type.
func TypeName(x interface{}) string {
return strings.ToLower(reflect.Indirect(reflect.ValueOf(x)).Type().Name())
}
// The type names provide consistent strings for types in error messages.
const (
NullTypeName = "null"
BooleanTypeName = "boolean"
StringTypeName = "string"
NumberTypeName = "number"
VarTypeName = "var"
RefTypeName = "ref"
ArrayTypeName = "array"
ObjectTypeName = "object"
SetTypeName = "set"
ArrayComprehensionTypeName = "arraycomprehension"
ExprTypeName = "expr"
WithTypeName = "with"
BodyTypeName = "body"
HeadTypeName = "head"
RuleTypeName = "rule"
FuncTypeName = "func"
FuncHeadTypeName = "funchead"
ArgsTypeName = "args"
ImportTypeName = "import"
PackageTypeName = "package"
)