MCPcopy
hub / github.com/rgburke/grv / isRegexComparison

Method isRegexComparison

cmd/grv/expression_processor.go:512–540  ·  view source on GitHub ↗
(fieldTypeDescriptor FieldTypeDescriptor)

Source from the content-addressed store, hash-verified

510}
511
512func (binaryExpression *BinaryExpression) isRegexComparison(fieldTypeDescriptor FieldTypeDescriptor) (isRegexComparison bool, regexString *StringLiteral, regexPtr *Expression) {
513 if binaryExpression.operator.operator.tokenType != QtkCmpRegexp {
514 return
515 }
516
517 identifier, ok := binaryExpression.lhs.(*Identifier)
518
519 if ok {
520 regexString, _ = binaryExpression.rhs.(*StringLiteral)
521 regexPtr = &binaryExpression.rhs
522 } else {
523 regexString, _ = binaryExpression.lhs.(*StringLiteral)
524 identifier, _ = binaryExpression.rhs.(*Identifier)
525 regexPtr = &binaryExpression.lhs
526 }
527
528 if identifier == nil || regexString == nil {
529 return
530 }
531
532 fieldType, fieldExists := fieldTypeDescriptor.FieldType(identifier.identifier.value)
533 if !fieldExists || fieldType != FtString {
534 return
535 }
536
537 isRegexComparison = true
538
539 return
540}
541
542// Validate the child expressions and operator are valid
543func (binaryExpression *BinaryExpression) Validate(fieldTypeDescriptor FieldTypeDescriptor) (errors []error) {

Callers 1

Calls 1

FieldTypeMethod · 0.65

Tested by

no test coverage detected