@@ -6672,10 +6672,13 @@ parser_lex(yp_parser_t *parser) {
6672
6672
LEX(YP_TOKEN_EOF);
6673
6673
}
6674
6674
6675
+ // Get a reference to the current mode.
6676
+ yp_lex_mode_t *mode = parser->lex_modes.current;
6677
+
6675
6678
// These are the places where we need to split up the content of the
6676
6679
// regular expression. We'll use strpbrk to find the first of these
6677
6680
// characters.
6678
- const char *breakpoints = parser->lex_modes.current ->as.regexp.breakpoints;
6681
+ const char *breakpoints = mode ->as.regexp.breakpoints;
6679
6682
const char *breakpoint = yp_strpbrk(parser, parser->current.end, breakpoints, parser->end - parser->current.end);
6680
6683
6681
6684
while (breakpoint != NULL) {
@@ -6700,14 +6703,15 @@ parser_lex(yp_parser_t *parser) {
6700
6703
break;
6701
6704
}
6702
6705
case '#': {
6703
- yp_token_type_t type = lex_interpolation(parser, breakpoint);
6704
- if (type != YP_TOKEN_NOT_PROVIDED) {
6705
- LEX(type);
6706
- }
6706
+ // If the terminator is #, then we need to fall into the
6707
+ // default case. Otherwise we'll attempt to lex
6708
+ // interpolation.
6709
+ if (mode->as.regexp.terminator != '#') {
6710
+ yp_token_type_t type = lex_interpolation(parser, breakpoint);
6711
+ if (type != YP_TOKEN_NOT_PROVIDED) {
6712
+ LEX(type);
6713
+ }
6707
6714
6708
- // We need to check if the terminator was # before skipping over
6709
- // to the next breakpoint
6710
- if (parser->lex_modes.current->as.regexp.terminator != '#') {
6711
6715
// If we haven't returned at this point then we had something
6712
6716
// that looked like an interpolated class or instance variable
6713
6717
// like "#@" but wasn't actually. In this case we'll just skip
@@ -6718,11 +6722,11 @@ parser_lex(yp_parser_t *parser) {
6718
6722
}
6719
6723
/* fallthrough */
6720
6724
default: {
6721
- if (*breakpoint == parser->lex_modes.current ->as.regexp.incrementor) {
6725
+ if (*breakpoint == mode ->as.regexp.incrementor) {
6722
6726
// If we've hit the incrementor, then we need to skip past it and
6723
6727
// find the next breakpoint.
6724
6728
breakpoint = yp_strpbrk(parser, breakpoint + 1, breakpoints, parser->end - (breakpoint + 1));
6725
- parser->lex_modes.current ->as.regexp.nesting++;
6729
+ mode ->as.regexp.nesting++;
6726
6730
break;
6727
6731
}
6728
6732
@@ -6731,7 +6735,7 @@ parser_lex(yp_parser_t *parser) {
6731
6735
// that in the list of newlines.
6732
6736
yp_newline_list_append(&parser->newline_list, breakpoint);
6733
6737
6734
- if (parser->lex_modes.current ->as.regexp.terminator != '\n') {
6738
+ if (mode ->as.regexp.terminator != '\n') {
6735
6739
// If the terminator is not a newline, then we
6736
6740
// can set the next breakpoint and continue.
6737
6741
breakpoint = yp_strpbrk(parser, breakpoint + 1, breakpoints, parser->end - (breakpoint + 1));
@@ -6742,11 +6746,11 @@ parser_lex(yp_parser_t *parser) {
6742
6746
// terminator so we need to continue on.
6743
6747
}
6744
6748
6745
- assert(*breakpoint == parser->lex_modes.current ->as.regexp.terminator);
6749
+ assert(*breakpoint == mode ->as.regexp.terminator);
6746
6750
6747
- if (parser->lex_modes.current ->as.regexp.nesting > 0) {
6751
+ if (mode ->as.regexp.nesting > 0) {
6748
6752
breakpoint = yp_strpbrk(parser, breakpoint + 1, breakpoints, parser->end - (breakpoint + 1));
6749
- parser->lex_modes.current ->as.regexp.nesting--;
6753
+ mode ->as.regexp.nesting--;
6750
6754
break;
6751
6755
}
6752
6756
0 commit comments