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

Function fxGetNextRegExp

xs/sources/xsLexical.c:531–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531void fxGetNextRegExp(txParser* parser, txU4 c)
532{
533 txString p;
534 txString q;
535 txBoolean backslash = 0;
536 txBoolean bracket = 0;
537 txBoolean first = 1;
538 txBoolean second = 1;
539 p = parser->buffer;
540 q = p + parser->bufferSize - 1;
541 if (!c) {
542 c = parser->character;
543 second = 0;
544 }
545 for (;;) {
546 if (c == (txU4)C_EOF) {
547 fxReportParserError(parser, parser->states[0].line, "end of file in regular expression");
548 break;
549 }
550 else if ((c == 10) || (c == 13) || (c == 0x2028) || (c == 0x2029)) {
551 fxReportParserError(parser, parser->states[0].line, "end of line in regular expression");
552 break;
553 }
554 else if (c == '*') {
555 if (first) {
556 fxReportParserError(parser, parser->states[0].line, "invalid regular expression");
557 break;
558 }
559 backslash = 0;
560 }
561 else if (c == '\\') {
562 if (!backslash)
563 backslash = 1;
564 else
565 backslash = 0;
566 }
567 else if (c == '[') {
568 if (!backslash)
569 bracket = 1;
570 backslash = 0;
571 }
572 else if (c == ']') {
573 if (!backslash)
574 bracket = 0;
575 backslash = 0;
576 }
577 else if (c == '/') {
578 if (!backslash && !bracket)
579 break;
580 backslash = 0;
581 }
582 else {
583 backslash = 0;
584 }
585 p = fxUTF8Buffer(parser, c, p, q);
586 if (second)
587 second = 0;
588 else

Callers 1

fxLiteralExpressionFunction · 0.85

Calls 6

fxReportParserErrorFunction · 0.85
fxUTF8BufferFunction · 0.85
fxGetNextCharacterFunction · 0.85
fxNewParserStringFunction · 0.85
fxIsIdentifierNextFunction · 0.85
fxCompileRegExpFunction · 0.85

Tested by

no test coverage detected