(fieldTypeDescriptor FieldTypeDescriptor)
| 510 | } |
| 511 | |
| 512 | func (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 |
| 543 | func (binaryExpression *BinaryExpression) Validate(fieldTypeDescriptor FieldTypeDescriptor) (errors []error) { |
no test coverage detected