• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

AsaiYusuke / jsonpath / 16410926563

21 Jul 2025 07:14AM UTC coverage: 17.851% (-79.5%) from 97.363%
16410926563

Pull #46

github

AsaiYusuke
refactor: move syntax and tests to internal directory

Separate directory structure from public API by relocating syntax
and test files under internal/ directory structure.
Pull Request #46: Move syntax to the internal directory and reorganize tests

181 of 406 new or added lines in 17 files covered. (44.58%)

3 existing lines in 1 file now uncovered.

676 of 3787 relevant lines covered (17.85%)

17.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.64
/internal/syntax/jsonpath_parser.go
1
package syntax
2

3
import (
4
        "encoding/json"
5
        "regexp"
6
        "strconv"
7

8
        "github.com/AsaiYusuke/jsonpath/errors"
9
)
10

11
type jsonPathParser struct {
12
        root               syntaxNode
13
        paramsList         [][]interface{}
14
        params             []interface{}
15
        unescapeRegex      *regexp.Regexp
16
        filterFunctions    map[string]func(interface{}) (interface{}, error)
17
        aggregateFunctions map[string]func([]interface{}) (interface{}, error)
18
        accessorMode       bool
19
}
20

21
func (p *jsonPathParser) saveParams() {
×
22
        if len(p.params) > 0 {
×
23
                p.paramsList = append(p.paramsList, p.params)
×
24
                p.params = nil
×
25
        }
×
26
}
27

28
func (p *jsonPathParser) loadParams() {
×
29
        if len(p.paramsList) > 0 {
×
30
                p.params = append(p.paramsList[len(p.paramsList)-1], p.params...)
×
31
                p.paramsList = p.paramsList[:len(p.paramsList)-1]
×
32
        }
×
33
}
34

35
func (p *jsonPathParser) push(param interface{}) {
1✔
36
        p.params = append(p.params, param)
1✔
37
}
1✔
38

39
func (p *jsonPathParser) pop() interface{} {
1✔
40
        var param interface{}
1✔
41
        param, p.params = p.params[len(p.params)-1], p.params[:len(p.params)-1]
1✔
42
        return param
1✔
43
}
1✔
44

45
func (p *jsonPathParser) toInt(text string) int {
×
46
        value, err := strconv.Atoi(text)
×
47
        if err != nil {
×
NEW
48
                panic(errors.NewErrorInvalidArgument(text, err))
×
49
        }
50
        return value
×
51
}
52

53
func (p *jsonPathParser) toFloat(text string) float64 {
×
54
        value, err := strconv.ParseFloat(text, 64)
×
55
        if err != nil {
×
NEW
56
                panic(errors.NewErrorInvalidArgument(text, err))
×
57
        }
58
        return value
×
59
}
60

61
func (p *jsonPathParser) unescape(text string) string {
×
62
        return p.unescapeRegex.ReplaceAllStringFunc(text, func(block string) string {
×
63
                varBlockSet := p.unescapeRegex.FindStringSubmatch(block)
×
64
                return varBlockSet[1]
×
65
        })
×
66
}
67

68
func (p *jsonPathParser) unescapeSingleQuotedString(text string) string {
12✔
69
        srcBytes := []byte(text)
12✔
70
        inputBytes := make([]byte, 0, 2+len(text))
12✔
71

12✔
72
        inputBytes = append(inputBytes, 0x22) // "
12✔
73

12✔
74
        var foundEscape bool
12✔
75
        for index := range srcBytes {
44✔
76
                switch srcBytes[index] {
32✔
77
                case 0x22: // "
1✔
78
                        // " -> /"
1✔
79
                        inputBytes = append(inputBytes, 0x5c, srcBytes[index])
1✔
80
                case 0x27: // '
2✔
81
                        // \' -> '
2✔
82
                        inputBytes = append(inputBytes, srcBytes[index])
2✔
83
                        foundEscape = false
2✔
84
                case 0x5c: // \
12✔
85
                        if foundEscape {
13✔
86
                                inputBytes = append(inputBytes, 0x5c, 0x5c)
1✔
87
                                foundEscape = false
1✔
88
                        } else {
12✔
89
                                foundEscape = true
11✔
90
                        }
11✔
91
                default:
17✔
92
                        if foundEscape {
26✔
93
                                inputBytes = append(inputBytes, 0x5c, srcBytes[index])
9✔
94
                                foundEscape = false
9✔
95
                        } else {
17✔
96
                                inputBytes = append(inputBytes, srcBytes[index])
8✔
97
                        }
8✔
98
                }
99
        }
100

101
        inputBytes = append(inputBytes, 0x22) // "
12✔
102

12✔
103
        unescapedText, err := p._unescapeJSONString(inputBytes)
12✔
104

12✔
105
        if err != nil {
13✔
106
                panic(errors.NewErrorInvalidArgument(text, err))
1✔
107
        }
108

109
        return unescapedText
11✔
110
}
111

112
func (p *jsonPathParser) unescapeDoubleQuotedString(text string) string {
11✔
113
        inputBytes := make([]byte, 0, 2+len(text))
11✔
114
        inputBytes = append(inputBytes, 0x22)
11✔
115
        inputBytes = append(inputBytes, []byte(text)...)
11✔
116
        inputBytes = append(inputBytes, 0x22)
11✔
117

11✔
118
        unescapedText, err := p._unescapeJSONString(inputBytes)
11✔
119

11✔
120
        if err != nil {
13✔
121
                panic(errors.NewErrorInvalidArgument(text, err))
2✔
122
        }
123

124
        return unescapedText
9✔
125
}
126

127
func (p *jsonPathParser) _unescapeJSONString(input []byte) (string, error) {
23✔
128
        var unescapedText string
23✔
129
        err := json.Unmarshal(input, &unescapedText)
23✔
130
        return unescapedText, err
23✔
131
}
23✔
132

133
func (p *jsonPathParser) syntaxErr(pos int, reason string, buffer string) error {
×
NEW
134
        return errors.NewErrorInvalidSyntax(pos, reason, buffer[pos:])
×
135
}
×
136

137
func (p *jsonPathParser) setNodeChain() {
1✔
138
        if len(p.params) > 1 {
1✔
139
                root := p.params[0].(syntaxNode)
×
140
                last := root
×
141
                for _, next := range p.params[1:] {
×
142
                        if funcNode, ok := next.(*syntaxAggregateFunction); ok {
×
143
                                funcNode.param = root
×
144
                                p.updateAccessorMode(funcNode.param, false)
×
145
                                root = funcNode
×
146
                                last = root
×
147
                                continue
×
148
                        }
149

150
                        nextNode := next.(syntaxNode)
×
151

×
152
                        if multiIdentifier, ok := last.(*syntaxChildMultiIdentifier); ok {
×
153
                                for _, singleIdentifier := range multiIdentifier.identifiers {
×
154
                                        singleIdentifier.setNext(nextNode)
×
155
                                }
×
156
                                if multiIdentifier.isAllWildcard {
×
157
                                        multiIdentifier.unionQualifier.setNext(nextNode)
×
158
                                }
×
159
                        }
160

161
                        last.setNext(nextNode)
×
162

×
163
                        last = nextNode
×
164
                }
165
                p.params = []interface{}{root}
×
166
        }
167
}
168

169
func (p *jsonPathParser) setConnectedText(targetNode syntaxNode, postfix ...string) {
1✔
170
        appendText := ``
1✔
171
        if targetNode.getNext() != nil {
1✔
172
                p.setConnectedText(targetNode.getNext(), postfix...)
×
173
                appendText = targetNode.getNext().getConnectedText()
×
174
        } else {
1✔
175
                if len(postfix) > 0 {
1✔
176
                        appendText = postfix[0]
×
177
                }
×
178
        }
179

180
        targetNode.setConnectedText(targetNode.getText() + appendText)
1✔
181

1✔
182
        if multiIdentifier, ok := targetNode.(*syntaxChildMultiIdentifier); ok {
1✔
183
                if multiIdentifier.isAllWildcard {
×
184
                        multiIdentifier.unionQualifier.setConnectedText(targetNode.getConnectedText())
×
185
                }
×
186
        }
187

188
        if aggregate, ok := targetNode.(*syntaxAggregateFunction); ok {
1✔
189
                p.setConnectedText(aggregate.param, aggregate.getConnectedText())
×
190
        }
×
191
}
192

193
func (p *jsonPathParser) updateRootValueGroup() {
1✔
194
        rootNode := p.params[0].(syntaxNode)
1✔
195
        checkNode := rootNode
1✔
196
        for checkNode != nil {
2✔
197
                if checkNode.isValueGroup() {
1✔
198
                        rootNode.setValueGroup()
×
199
                        break
×
200
                }
201
                checkNode = checkNode.getNext()
1✔
202
        }
203
}
204

205
func (p *jsonPathParser) deleteRootNodeIdentifier(targetNode syntaxNode) syntaxNode {
1✔
206
        switch targetNode.(type) {
1✔
207
        case *syntaxRootNodeIdentifier, *syntaxCurrentNodeIdentifier:
1✔
208
                if targetNode.getNext() != nil {
1✔
209
                        if targetNode.isValueGroup() {
×
210
                                targetNode.getNext().setValueGroup()
×
211
                        }
×
212
                        targetNode.setNext(nil)
×
213
                        targetNode = targetNode.getNext()
×
214
                }
215
                return targetNode
1✔
216
        }
217

218
        if aggregateFunction, ok := targetNode.(*syntaxAggregateFunction); ok {
×
219
                aggregateFunction.param = p.deleteRootNodeIdentifier(aggregateFunction.param)
×
220
        }
×
221

222
        return targetNode
×
223
}
224

225
func (p *jsonPathParser) setLastNodeText(text string) {
×
226
        node := p.params[len(p.params)-1].(syntaxNode)
×
227
        node.setText(text)
×
228

×
229
        if multiIdentifier, ok := node.(*syntaxChildMultiIdentifier); ok {
×
230
                if multiIdentifier.isAllWildcard {
×
231
                        multiIdentifier.unionQualifier.setText(text)
×
232
                }
×
233
        }
234
}
235

236
func (p *jsonPathParser) updateAccessorMode(checkNode syntaxNode, mode bool) {
×
237
        for checkNode != nil {
×
238
                checkNode.setAccessorMode(mode)
×
239
                checkNode = checkNode.getNext()
×
240
        }
×
241
}
242

243
func (p *jsonPathParser) pushFunction(text string, funcName string) {
×
244
        if function, ok := p.filterFunctions[funcName]; ok {
×
245
                functionNode := syntaxFilterFunction{
×
246
                        syntaxBasicNode: &syntaxBasicNode{
×
247
                                text:         text,
×
248
                                accessorMode: p.accessorMode,
×
249
                        },
×
250
                        function: function,
×
251
                }
×
252

×
253
                functionNode.errorRuntime = &errorBasicRuntime{
×
254
                        node: functionNode.syntaxBasicNode,
×
255
                }
×
256

×
257
                p.push(&functionNode)
×
258
                return
×
259
        }
×
260
        if function, ok := p.aggregateFunctions[funcName]; ok {
×
261
                functionNode := syntaxAggregateFunction{
×
262
                        syntaxBasicNode: &syntaxBasicNode{
×
263
                                text:         text,
×
264
                                accessorMode: p.accessorMode,
×
265
                        },
×
266
                        function: function,
×
267
                }
×
268

×
269
                functionNode.errorRuntime = &errorBasicRuntime{
×
270
                        node: functionNode.syntaxBasicNode,
×
271
                }
×
272

×
273
                p.push(&functionNode)
×
274
                return
×
275
        }
×
276

NEW
277
        panic(errors.NewErrorFunctionNotFound(text))
×
278
}
279

280
func (p *jsonPathParser) pushRootNodeIdentifier() {
1✔
281
        p.push(&syntaxRootNodeIdentifier{
1✔
282
                syntaxBasicNode: &syntaxBasicNode{
1✔
283
                        text:         `$`,
1✔
284
                        accessorMode: p.accessorMode,
1✔
285
                },
1✔
286
        })
1✔
287
}
1✔
288

289
func (p *jsonPathParser) pushCurrentNodeIdentifier() {
×
290
        p.push(&syntaxCurrentNodeIdentifier{
×
291
                syntaxBasicNode: &syntaxBasicNode{
×
292
                        text:         `@`,
×
293
                        accessorMode: p.accessorMode,
×
294
                },
×
295
        })
×
296
}
×
297

298
func (p *jsonPathParser) pushChildSingleIdentifier(text string) {
×
299
        identifier := syntaxChildSingleIdentifier{
×
300
                syntaxBasicNode: &syntaxBasicNode{
×
301
                        text:         text,
×
302
                        valueGroup:   false,
×
303
                        accessorMode: p.accessorMode,
×
304
                },
×
305
                identifier: text,
×
306
        }
×
307

×
308
        identifier.errorRuntime = &errorBasicRuntime{
×
309
                node: identifier.syntaxBasicNode,
×
310
        }
×
311

×
312
        p.push(&identifier)
×
313
}
×
314

315
func (p *jsonPathParser) pushChildMultiIdentifier(
316
        node syntaxNode, appendNode syntaxNode) {
×
317

×
318
        if multiIdentifier, ok := node.(*syntaxChildMultiIdentifier); ok {
×
319
                multiIdentifier.identifiers = append(multiIdentifier.identifiers, appendNode)
×
320

×
321
                _, isWildcard := appendNode.(*syntaxChildWildcardIdentifier)
×
322
                multiIdentifier.isAllWildcard = multiIdentifier.isAllWildcard && isWildcard
×
323

×
324
                if multiIdentifier.isAllWildcard {
×
325
                        multiIdentifier.unionQualifier.subscripts = append(
×
326
                                multiIdentifier.unionQualifier.subscripts,
×
327
                                &syntaxWildcardSubscript{},
×
328
                        )
×
329
                } else {
×
330
                        multiIdentifier.unionQualifier = syntaxUnionQualifier{}
×
331
                }
×
332

333
                p.push(multiIdentifier)
×
334
                return
×
335
        }
336

337
        _, isNodeWildcard := node.(*syntaxChildWildcardIdentifier)
×
338
        _, isAppendNodeWildcard := appendNode.(*syntaxChildWildcardIdentifier)
×
339

×
340
        identifier := syntaxChildMultiIdentifier{
×
341
                syntaxBasicNode: &syntaxBasicNode{
×
342
                        valueGroup:   true,
×
343
                        accessorMode: p.accessorMode,
×
344
                },
×
345
                identifiers: []syntaxNode{
×
346
                        node,
×
347
                        appendNode,
×
348
                },
×
349
                isAllWildcard: isNodeWildcard && isAppendNodeWildcard,
×
350
        }
×
351

×
352
        identifier.errorRuntime = &errorBasicRuntime{
×
353
                node: identifier.syntaxBasicNode,
×
354
        }
×
355

×
356
        if identifier.isAllWildcard {
×
357
                identifier.unionQualifier = syntaxUnionQualifier{
×
358
                        syntaxBasicNode: &syntaxBasicNode{
×
359
                                valueGroup:   true,
×
360
                                accessorMode: p.accessorMode,
×
361
                        },
×
362
                        subscripts: []syntaxSubscript{
×
363
                                &syntaxWildcardSubscript{},
×
364
                                &syntaxWildcardSubscript{},
×
365
                        },
×
366
                }
×
367

×
368
                identifier.unionQualifier.errorRuntime = &errorBasicRuntime{
×
369
                        node: identifier.unionQualifier.syntaxBasicNode,
×
370
                }
×
371
        }
×
372

373
        p.push(&identifier)
×
374
}
375

376
func (p *jsonPathParser) pushChildWildcardIdentifier() {
×
377
        identifier := syntaxChildWildcardIdentifier{
×
378
                syntaxBasicNode: &syntaxBasicNode{
×
379
                        text:         `*`,
×
380
                        valueGroup:   true,
×
381
                        accessorMode: p.accessorMode,
×
382
                },
×
383
        }
×
384

×
385
        identifier.errorRuntime = &errorBasicRuntime{
×
386
                node: identifier.syntaxBasicNode,
×
387
        }
×
388

×
389
        p.push(&identifier)
×
390
}
×
391

392
func (p *jsonPathParser) pushRecursiveChildIdentifier(node syntaxNode) {
×
393
        var nextMapRequired, nextListRequired bool
×
394
        switch node.(type) {
×
395
        case *syntaxChildWildcardIdentifier, *syntaxChildMultiIdentifier, *syntaxFilterQualifier:
×
396
                nextMapRequired = true
×
397
                nextListRequired = true
×
398
        case *syntaxChildSingleIdentifier:
×
399
                nextMapRequired = true
×
400
        case *syntaxUnionQualifier:
×
401
                nextListRequired = true
×
402
        }
403

404
        identifier := syntaxRecursiveChildIdentifier{
×
405
                syntaxBasicNode: &syntaxBasicNode{
×
406
                        text:         `..`,
×
407
                        valueGroup:   true,
×
408
                        next:         node,
×
409
                        accessorMode: p.accessorMode,
×
410
                },
×
411
                nextMapRequired:  nextMapRequired,
×
412
                nextListRequired: nextListRequired,
×
413
        }
×
414

×
415
        identifier.errorRuntime = &errorBasicRuntime{
×
416
                node: identifier.syntaxBasicNode,
×
417
        }
×
418

×
419
        p.push(&identifier)
×
420
}
421

422
func (p *jsonPathParser) pushUnionQualifier(subscript syntaxSubscript) {
×
423
        qualifier := syntaxUnionQualifier{
×
424
                syntaxBasicNode: &syntaxBasicNode{
×
425
                        valueGroup:   subscript.isValueGroup(),
×
426
                        accessorMode: p.accessorMode,
×
427
                },
×
428
                subscripts: []syntaxSubscript{subscript},
×
429
        }
×
430

×
431
        qualifier.errorRuntime = &errorBasicRuntime{
×
432
                node: qualifier.syntaxBasicNode,
×
433
        }
×
434

×
435
        p.push(&qualifier)
×
436
}
×
437

438
func (p *jsonPathParser) pushFilterQualifier(query syntaxQuery) {
×
439
        qualifier := syntaxFilterQualifier{
×
440
                syntaxBasicNode: &syntaxBasicNode{
×
441
                        valueGroup:   true,
×
442
                        accessorMode: p.accessorMode,
×
443
                },
×
444
                query: query,
×
445
        }
×
446

×
447
        qualifier.errorRuntime = &errorBasicRuntime{
×
448
                node: qualifier.syntaxBasicNode,
×
449
        }
×
450

×
451
        p.push(&qualifier)
×
452
}
×
453

454
func (p *jsonPathParser) pushScriptQualifier(text string) {
×
NEW
455
        panic(errors.NewErrorNotSupported("script", "[("+text+")]"))
×
456
}
457

458
func (p *jsonPathParser) pushSlicePositiveStepSubscript(start, end, step *syntaxIndexSubscript) {
×
459
        p.push(&syntaxSlicePositiveStepSubscript{
×
460
                syntaxBasicSubscript: &syntaxBasicSubscript{
×
461
                        valueGroup: true,
×
462
                },
×
463
                start: start,
×
464
                end:   end,
×
465
                step:  step,
×
466
        })
×
467
}
×
468

469
func (p *jsonPathParser) pushSliceNegativeStepSubscript(start, end, step *syntaxIndexSubscript) {
×
470
        p.push(&syntaxSliceNegativeStepSubscript{
×
471
                syntaxBasicSubscript: &syntaxBasicSubscript{
×
472
                        valueGroup: true,
×
473
                },
×
474
                start: start,
×
475
                end:   end,
×
476
                step:  step,
×
477
        })
×
478
}
×
479

480
func (p *jsonPathParser) _pushIndexSubscript(text string, isOmitted bool) {
×
481
        p.push(&syntaxIndexSubscript{
×
482
                syntaxBasicSubscript: &syntaxBasicSubscript{
×
483
                        valueGroup: false,
×
484
                },
×
485
                number:    p.toInt(text),
×
486
                isOmitted: isOmitted,
×
487
        })
×
488
}
×
489

490
func (p *jsonPathParser) pushIndexSubscript(text string) {
×
491
        p._pushIndexSubscript(text, false)
×
492
}
×
493

494
func (p *jsonPathParser) pushOmittedIndexSubscript(text string) {
×
495
        p._pushIndexSubscript(text, true)
×
496
}
×
497

498
func (p *jsonPathParser) pushWildcardSubscript() {
×
499
        p.push(&syntaxWildcardSubscript{
×
500
                syntaxBasicSubscript: &syntaxBasicSubscript{
×
501
                        valueGroup: true,
×
502
                },
×
503
        })
×
504
}
×
505

506
func (p *jsonPathParser) pushLogicalOr(leftQuery, rightQuery syntaxQuery) {
×
507
        p.push(&syntaxLogicalOr{
×
508
                leftQuery:  leftQuery,
×
509
                rightQuery: rightQuery,
×
510
        })
×
511
}
×
512

513
func (p *jsonPathParser) pushLogicalAnd(leftQuery, rightQuery syntaxQuery) {
×
514
        p.push(&syntaxLogicalAnd{
×
515
                leftQuery:  leftQuery,
×
516
                rightQuery: rightQuery,
×
517
        })
×
518
}
×
519

520
func (p *jsonPathParser) pushLogicalNot(query syntaxQuery) {
×
521
        p.push(&syntaxLogicalNot{
×
522
                query: query,
×
523
        })
×
524
}
×
525

526
func (p *jsonPathParser) _createBasicCompareQuery(
527
        leftParam, rightParam *syntaxBasicCompareParameter,
528
        comparator syntaxComparator) syntaxQuery {
×
529

×
530
        return &syntaxBasicCompareQuery{
×
531
                leftParam:  leftParam,
×
532
                rightParam: rightParam,
×
533
                comparator: comparator,
×
534
        }
×
535
}
×
536

537
func (p *jsonPathParser) pushCompareEQ(
538
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
539
        if leftParam.isLiteral {
×
540
                rightParam, leftParam = leftParam, rightParam
×
541
        }
×
542

543
        if rightLiteralParam, ok := rightParam.param.(*syntaxQueryParamLiteral); ok {
×
544
                switch rightLiteralParam.literal[0].(type) {
×
545
                case float64:
×
546
                        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareDirectEQ{
×
547
                                syntaxTypeValidator: &syntaxBasicNumericTypeValidator{},
×
548
                        }))
×
549
                case bool:
×
550
                        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareDirectEQ{
×
551
                                syntaxTypeValidator: &syntaxBasicBoolTypeValidator{},
×
552
                        }))
×
553
                case string:
×
554
                        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareDirectEQ{
×
555
                                syntaxTypeValidator: &syntaxBasicStringTypeValidator{},
×
556
                        }))
×
557
                case nil:
×
558
                        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareDirectEQ{
×
559
                                syntaxTypeValidator: &syntaxBasicNilTypeValidator{},
×
560
                        }))
×
561
                }
562

563
                return
×
564
        }
565

566
        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareDeepEQ{}))
×
567
}
568

569
func (p *jsonPathParser) pushCompareNE(
570
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
571
        p.pushCompareEQ(leftParam, rightParam)
×
572
        p.push(&syntaxLogicalNot{query: p.pop().(syntaxQuery)})
×
573
}
×
574

575
func (p *jsonPathParser) pushCompareGE(
576
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
577
        if leftParam.isLiteral {
×
578
                p.pushCompareLE(rightParam, leftParam)
×
579
                return
×
580
        }
×
581
        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareGE{}))
×
582
}
583

584
func (p *jsonPathParser) pushCompareGT(
585
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
586
        if leftParam.isLiteral {
×
587
                p.pushCompareLT(rightParam, leftParam)
×
588
                return
×
589
        }
×
590
        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareGT{}))
×
591
}
592

593
func (p *jsonPathParser) pushCompareLE(
594
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
595
        if leftParam.isLiteral {
×
596
                p.pushCompareGE(rightParam, leftParam)
×
597
                return
×
598
        }
×
599
        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareLE{}))
×
600
}
601

602
func (p *jsonPathParser) pushCompareLT(
603
        leftParam, rightParam *syntaxBasicCompareParameter) {
×
604
        if leftParam.isLiteral {
×
605
                p.pushCompareGT(rightParam, leftParam)
×
606
                return
×
607
        }
×
608
        p.push(p._createBasicCompareQuery(leftParam, rightParam, &syntaxCompareLT{}))
×
609
}
610

611
func (p *jsonPathParser) pushCompareRegex(
612
        leftParam *syntaxBasicCompareParameter, regex string) {
×
613
        regexParam, err := regexp.Compile(regex)
×
614
        if err != nil {
×
NEW
615
                panic(errors.NewErrorInvalidArgument(regex, err))
×
616
        }
617

618
        p.push(p._createBasicCompareQuery(
×
619
                leftParam, &syntaxBasicCompareParameter{
×
620
                        param: &syntaxQueryParamLiteral{
×
621
                                literal: []interface{}{`regex`},
×
622
                        },
×
623
                        isLiteral: true,
×
624
                },
×
625
                &syntaxCompareRegex{
×
626
                        regex: regexParam,
×
627
                }))
×
628
}
629

630
func (p *jsonPathParser) pushBasicCompareParameter(
631
        parameter syntaxQuery, isLiteral bool) {
×
632
        p.push(&syntaxBasicCompareParameter{
×
633
                param:     parameter,
×
634
                isLiteral: isLiteral,
×
635
        })
×
636
}
×
637

638
func (p *jsonPathParser) pushCompareParameterLiteral(text interface{}) {
×
639
        p.pushBasicCompareParameter(
×
640
                &syntaxQueryParamLiteral{
×
641
                        literal: []interface{}{text},
×
642
                }, true)
×
643
}
×
644

645
func (p *jsonPathParser) pushCompareParameterRoot(node syntaxNode) {
×
646
        p.updateAccessorMode(node, false)
×
647
        p.push(&syntaxQueryParamRootNode{
×
648
                param: node,
×
649
        })
×
650
}
×
651

652
func (p *jsonPathParser) pushCompareParameterCurrentNode(node syntaxNode) {
×
653
        p.updateAccessorMode(node, false)
×
654
        p.push(&syntaxQueryParamCurrentNode{
×
655
                param: node,
×
656
        })
×
657
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc