| 1580 | } |
| 1581 | |
| 1582 | void* fxQuantifierParse(txPatternParser* parser, void* term, txInteger captureIndex) |
| 1583 | { |
| 1584 | txInteger min, max; |
| 1585 | txBoolean greedy; |
| 1586 | txQuantifier* quantifier; |
| 1587 | switch (parser->character) { |
| 1588 | case '*': |
| 1589 | min = 0; |
| 1590 | max = 0x7FFFFFFF; |
| 1591 | fxPatternParserNext(parser); |
| 1592 | break; |
| 1593 | case '+': |
| 1594 | min = 1; |
| 1595 | max = 0x7FFFFFFF; |
| 1596 | fxPatternParserNext(parser); |
| 1597 | break; |
| 1598 | case '?': |
| 1599 | min = 0; |
| 1600 | max = 1; |
| 1601 | fxPatternParserNext(parser); |
| 1602 | break; |
| 1603 | case '{': |
| 1604 | if (fxQuantifierParseBrace(parser, &min, &max)) { |
| 1605 | if (min > max) |
| 1606 | fxPatternParserError(parser, gxErrors[mxInvalidQuantifier]); |
| 1607 | break; |
| 1608 | } |
| 1609 | // continue |
| 1610 | mxFallThrough; |
| 1611 | default: |
| 1612 | return term; |
| 1613 | } |
| 1614 | if (parser->character == '?') { |
| 1615 | greedy = 0; |
| 1616 | fxPatternParserNext(parser); |
| 1617 | } |
| 1618 | else |
| 1619 | greedy = 1; |
| 1620 | quantifier = fxPatternParserCreateTerm(parser, sizeof(txQuantifier), fxQuantifierMeasure); |
| 1621 | quantifier->term = term; |
| 1622 | quantifier->min = min; |
| 1623 | quantifier->max = max; |
| 1624 | quantifier->greedy = greedy; |
| 1625 | quantifier->captureIndex = captureIndex; |
| 1626 | quantifier->captureCount = parser->captureIndex - captureIndex; |
| 1627 | quantifier->quantifierIndex = parser->quantifierIndex++; |
| 1628 | return quantifier; |
| 1629 | } |
| 1630 | |
| 1631 | txBoolean fxQuantifierParseBrace(txPatternParser* parser, txInteger* min, txInteger* max) |
| 1632 | { |
no test coverage detected