tree.go 941 B

123456789101112131415161718192021222324252627282930313233
  1. package ast
  2. // FilterNode is the the base instance of a tree leaf node, which is a conditional operator
  3. // which contains operands that may also be leaf nodes. A go type-switch should be used to
  4. // reduce the FilterNode to a concrete type to operate on. If only the type of operator is
  5. // required, the `Op()` field can be used.
  6. type FilterNode interface {
  7. Op() FilterOp
  8. }
  9. // FilterGroup is a specialized interface for ops which can collect N operands.
  10. type FilterGroup interface {
  11. FilterNode
  12. // Adds a new leaf node to the FilterGroup
  13. Add(FilterNode)
  14. }
  15. // Identifier is a struct that contains the data required to resolve a specific operand to a concrete
  16. // value during operator compilation.
  17. type Identifier struct {
  18. Field *Field
  19. Key string
  20. }
  21. // String returns the string representation for the Identifier
  22. func (id *Identifier) String() string {
  23. s := id.Field.Name
  24. if id.Key != "" {
  25. s += "[" + id.Key + "]"
  26. }
  27. return s
  28. }