| 1 | package ast |
| 2 | |
| 3 | import "github.com/tomwright/dasel/v3/selector/lexer" |
| 4 | |
| 5 | type BinaryExpr struct { |
| 6 | Left Expr |
| 7 | Operator lexer.Token |
| 8 | Right Expr |
| 9 | } |
| 10 | |
| 11 | func (BinaryExpr) expr() {} |
| 12 | |
| 13 | type UnaryExpr struct { |
| 14 | Operator lexer.Token |
| 15 | Right Expr |
| 16 | } |
| 17 | |
| 18 | func (UnaryExpr) expr() {} |
| 19 | |
| 20 | type CallExpr struct { |
| 21 | Function string |
| 22 | Args Expressions |
| 23 | } |
| 24 | |
| 25 | func (CallExpr) expr() {} |
| 26 | |
| 27 | type ChainedExpr struct { |
| 28 | Exprs Expressions |
| 29 | } |
| 30 | |
| 31 | func ChainExprs(exprs ...Expr) Expr { |
| 32 | if len(exprs) == 0 { |
| 33 | return nil |
| 34 | } |
| 35 | if len(exprs) == 1 { |
| 36 | return exprs[0] |
| 37 | } |
| 38 | return ChainedExpr{ |
| 39 | Exprs: exprs, |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func (ChainedExpr) expr() {} |
| 44 | |
| 45 | type SpreadExpr struct{} |
| 46 | |
| 47 | func (SpreadExpr) expr() {} |
| 48 | |
| 49 | type RangeExpr struct { |
| 50 | Start Expr |
| 51 | End Expr |
| 52 | } |
| 53 | |
| 54 | func (RangeExpr) expr() {} |
| 55 | |
| 56 | type IndexExpr struct { |
| 57 | Index Expr |
| 58 | } |
| 59 | |
| 60 | func (IndexExpr) expr() {} |
| 61 | |
| 62 | type ArrayExpr struct { |
| 63 | Exprs Expressions |
| 64 | } |
| 65 | |
| 66 | func (ArrayExpr) expr() {} |
| 67 | |
| 68 | type PropertyExpr struct { |
| 69 | // Property can resolve to a string or number. |
| 70 | // If it resolves to a number, we expect to be reading from an array. |
| 71 | // If it resolves to a string, we expect to be reading from a map. |
| 72 | Property Expr |
| 73 | } |
| 74 | |
| 75 | func (PropertyExpr) expr() {} |
| 76 | |
| 77 | type KeyValue struct { |
| 78 | Key Expr |
| 79 | Value Expr |
| 80 | } |
| 81 | |
| 82 | type ObjectExpr struct { |
| 83 | Pairs []KeyValue |
| 84 | } |
| 85 | |
| 86 | func (ObjectExpr) expr() {} |
| 87 | |
| 88 | type MapExpr struct { |
| 89 | Expr Expr |
| 90 | } |
| 91 | |
| 92 | func (MapExpr) expr() {} |
| 93 | |
| 94 | type EachExpr struct { |
| 95 | Expr Expr |
| 96 | } |
| 97 | |
| 98 | func (EachExpr) expr() {} |
| 99 | |
| 100 | type FilterExpr struct { |
| 101 | Expr Expr |
| 102 | } |
| 103 | |
| 104 | func (FilterExpr) expr() {} |
| 105 | |
| 106 | type SearchExpr struct { |
| 107 | Expr Expr |
| 108 | } |
| 109 | |
| 110 | func (SearchExpr) expr() {} |
| 111 | |
| 112 | type RecursiveDescentExpr struct { |
| 113 | IsWildcard bool |
| 114 | Expr Expr |
| 115 | } |
| 116 | |
| 117 | func (RecursiveDescentExpr) expr() {} |
| 118 | |
| 119 | type SortByExpr struct { |
| 120 | Expr Expr |
| 121 | Descending bool |
| 122 | } |
| 123 | |
| 124 | func (SortByExpr) expr() {} |
| 125 | |
| 126 | type GroupByExpr struct { |
| 127 | Expr Expr |
| 128 | } |
| 129 | |
| 130 | func (GroupByExpr) expr() {} |
| 131 | |
| 132 | type ReduceExpr struct { |
| 133 | Expr Expr |
| 134 | Init Expr |
| 135 | Update Expr |
| 136 | } |
| 137 | |
| 138 | func (ReduceExpr) expr() {} |
| 139 | |
| 140 | type MapValuesExpr struct { |
| 141 | Expr Expr |
| 142 | } |
| 143 | |
| 144 | func (MapValuesExpr) expr() {} |
| 145 | |
| 146 | type AnyExpr struct { |
| 147 | Expr Expr |
| 148 | } |
| 149 | |
| 150 | func (AnyExpr) expr() {} |
| 151 | |
| 152 | type AllExpr struct { |
| 153 | Expr Expr |
| 154 | } |
| 155 | |
| 156 | func (AllExpr) expr() {} |
| 157 | |
| 158 | type CountExpr struct { |
| 159 | Expr Expr |
| 160 | } |
| 161 | |
| 162 | func (CountExpr) expr() {} |
| 163 | |
| 164 | type VariableExpr struct { |
| 165 | Name string |
| 166 | } |
| 167 | |
| 168 | func (VariableExpr) expr() {} |
| 169 | |
| 170 | type GroupExpr struct { |
| 171 | Expr Expr |
| 172 | } |
| 173 | |
| 174 | func (GroupExpr) expr() {} |
| 175 | |
| 176 | type ConditionalExpr struct { |
| 177 | Cond Expr |
| 178 | Then Expr |
| 179 | Else Expr |
| 180 | } |
| 181 | |
| 182 | func (ConditionalExpr) expr() {} |
| 183 | |
| 184 | type BranchExpr struct { |
| 185 | Exprs []Expr |
| 186 | } |
| 187 | |
| 188 | func (BranchExpr) expr() {} |
| 189 | |
| 190 | func BranchExprs(exprs ...Expr) Expr { |
| 191 | return BranchExpr{ |
| 192 | Exprs: exprs, |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | type AssignExpr struct { |
| 197 | Variable VariableExpr |
| 198 | Value Expr |
| 199 | } |
| 200 | |
| 201 | func (AssignExpr) expr() {} |