github.com/authzed/spicedb@v1.32.1-0.20240520085336-ebda56537386/pkg/schemadsl/dslshape/dslshape.go (about) 1 //go:generate go run golang.org/x/tools/cmd/stringer -type=NodeType -output zz_generated.nodetype_string.go 2 3 // Package dslshape defines the types representing the structure of schema DSL. 4 package dslshape 5 6 // NodeType identifies the type of AST node. 7 type NodeType int 8 9 const ( 10 // Top-level 11 NodeTypeError NodeType = iota // error occurred; value is text of error 12 NodeTypeFile // The file root node 13 NodeTypeComment // A single or multiline comment 14 15 NodeTypeDefinition // A definition. 16 NodeTypeCaveatDefinition // A caveat definition. 17 18 NodeTypeCaveatParameter // A caveat parameter. 19 NodeTypeCaveatExpression // A caveat expression. 20 21 NodeTypeRelation // A relation 22 NodeTypePermission // A permission 23 24 NodeTypeTypeReference // A type reference 25 NodeTypeSpecificTypeReference // A reference to a specific type. 26 NodeTypeCaveatReference // A caveat reference under a type. 27 28 NodeTypeUnionExpression 29 NodeTypeIntersectExpression 30 NodeTypeExclusionExpression 31 32 NodeTypeArrowExpression // A TTU in arrow form. 33 34 NodeTypeIdentifier // An identifier under an expression. 35 NodeTypeNilExpression // A nil keyword 36 37 NodeTypeCaveatTypeReference // A type reference for a caveat parameter. 38 ) 39 40 const ( 41 // 42 // All nodes 43 // 44 // The source of this node. 45 NodePredicateSource = "input-source" 46 47 // The rune position in the input string at which this node begins. 48 NodePredicateStartRune = "start-rune" 49 50 // The rune position in the input string at which this node ends. 51 NodePredicateEndRune = "end-rune" 52 53 // A direct child of this node. Implementations should handle the ordering 54 // automatically for this predicate. 55 NodePredicateChild = "child-node" 56 57 // 58 // NodeTypeError 59 // 60 61 // The message for the parsing error. 62 NodePredicateErrorMessage = "error-message" 63 64 // The (optional) source to highlight for the parsing error. 65 NodePredicateErrorSource = "error-source" 66 67 // 68 // NodeTypeComment 69 // 70 71 // The value of the comment, including its delimeter(s) 72 NodeCommentPredicateValue = "comment-value" 73 74 // 75 // NodeTypeDefinition 76 // 77 78 // The name of the definition 79 NodeDefinitionPredicateName = "definition-name" 80 81 // 82 // NodeTypeCaveatDefinition 83 // 84 85 // The name of the definition 86 NodeCaveatDefinitionPredicateName = "caveat-definition-name" 87 88 // The parameters for the definition. 89 NodeCaveatDefinitionPredicateParameters = "parameters" 90 91 // The link to the expression for the definition. 92 NodeCaveatDefinitionPredicateExpession = "caveat-definition-expression" 93 94 // 95 // NodeTypeCaveatExpression 96 // 97 98 // The raw CEL expression, in string form. 99 NodeCaveatExpressionPredicateExpression = "caveat-expression-expressionstr" 100 101 // 102 // NodeTypeCaveatParameter 103 // 104 105 // The name of the parameter 106 NodeCaveatParameterPredicateName = "caveat-parameter-name" 107 108 // The defined type of the caveat parameter. 109 NodeCaveatParameterPredicateType = "caveat-parameter-type" 110 111 // 112 // NodeTypeCaveatTypeReference 113 // 114 115 // The type for the caveat type reference. 116 NodeCaveatTypeReferencePredicateType = "type-name" 117 118 // The child type(s) for the type reference. 119 NodeCaveatTypeReferencePredicateChildTypes = "child-types" 120 121 // 122 // NodeTypeRelation + NodeTypePermission 123 // 124 125 // The name of the relation/permission 126 NodePredicateName = "relation-name" 127 128 // 129 // NodeTypeRelation 130 // 131 132 // The allowed types for the relation. 133 NodeRelationPredicateAllowedTypes = "allowed-types" 134 135 // 136 // NodeTypeTypeReference 137 // 138 139 // A type under a type reference. 140 NodeTypeReferencePredicateType = "type-ref-type" 141 142 // 143 // NodeTypeSpecificTypeReference 144 // 145 146 // A type under a type reference. 147 NodeSpecificReferencePredicateType = "type-name" 148 149 // A relation under a type reference. 150 NodeSpecificReferencePredicateRelation = "relation-name" 151 152 // A wildcard under a type reference. 153 NodeSpecificReferencePredicateWildcard = "type-wildcard" 154 155 // A caveat under a type reference. 156 NodeSpecificReferencePredicateCaveat = "caveat" 157 158 // 159 // NodeTypeCaveatReference 160 // 161 162 // The caveat name under the caveat. 163 NodeCaveatPredicateCaveat = "caveat-name" 164 165 // 166 // NodeTypePermission 167 // 168 169 // The expression to compute the permission. 170 NodePermissionPredicateComputeExpression = "compute-expression" 171 172 // 173 // NodeTypeIdentifer 174 // 175 176 // The value of the identifier. 177 NodeIdentiferPredicateValue = "identifier-value" 178 179 // 180 // NodeTypeUnionExpression + NodeTypeIntersectExpression + NodeTypeExclusionExpression + NodeTypeArrowExpression 181 // 182 NodeExpressionPredicateLeftExpr = "left-expr" 183 NodeExpressionPredicateRightExpr = "right-expr" 184 )