MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxModifiersParse

Function fxModifiersParse

xs/sources/xsre.c:1535–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1533}
1534
1535void* fxModifiersParse(txPatternParser* parser)
1536{
1537 txUnsigned add = 0, remove = 0, flags = parser->flags;
1538 txModifiers* self = fxPatternParserCreateTerm(parser, sizeof(txModifiers), fxModifiersMeasure);;
1539 while (parser->character != ':') {
1540 if (parser->character == '-') {
1541 fxPatternParserNext(parser);
1542 break;
1543 }
1544 if ((parser->character == 'i') && !(add & XS_REGEXP_I))
1545 add |= XS_REGEXP_I;
1546 else if ((parser->character == 'm') && !(add & XS_REGEXP_M))
1547 add |= XS_REGEXP_M;
1548 else if ((parser->character == 's') && !(add & XS_REGEXP_S))
1549 add |= XS_REGEXP_S;
1550 else
1551 goto bail;
1552 fxPatternParserNext(parser);
1553 }
1554 while (parser->character != ':') {
1555 if ((parser->character == 'i') && !(remove & XS_REGEXP_I))
1556 remove |= XS_REGEXP_I;
1557 else if ((parser->character == 'm') && !(remove & XS_REGEXP_M))
1558 remove |= XS_REGEXP_M;
1559 else if ((parser->character == 's') && !(remove & XS_REGEXP_S))
1560 remove |= XS_REGEXP_S;
1561 else
1562 goto bail;
1563 fxPatternParserNext(parser);
1564 }
1565 if (!add && !remove)
1566 goto bail;
1567 if (add & remove)
1568 goto bail;
1569 parser->flags = (flags | add) & ~remove;
1570 fxPatternParserNext(parser);
1571 self->add = add;
1572 self->remove = remove;
1573 self->disjunction = fxDisjunctionParse(parser, ')');
1574 fxPatternParserNext(parser);
1575 parser->flags = flags;
1576 return self;
1577bail:
1578 fxPatternParserError(parser, gxErrors[mxInvalidModifiers]);
1579 return C_NULL;
1580}
1581
1582void* fxQuantifierParse(txPatternParser* parser, void* term, txInteger captureIndex)
1583{

Callers 1

fxSequenceParseFunction · 0.85

Calls 4

fxPatternParserNextFunction · 0.85
fxDisjunctionParseFunction · 0.85
fxPatternParserErrorFunction · 0.85

Tested by

no test coverage detected