node_modules/gulp-sass/node_modules/node-sass/src/libsass/src/parser.cpp
// this parses interpolation inside other strings
// means the result should later be quoted again
this parses interpolation inside other strings
means the result should later be quoted again
this parses interpolation inside other strings means the result should later be quoted again
String* Parser::parse_interpolated_chunk(Token chunk, bool constant)
  {
    const char* i = chunk.begin;
    const char* p = find_first_in_interval< exactly<hash_lbrace> >(i, chunk.end);
    if (!p) {
      String_Quoted* str_quoted = SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, std::string(i, chunk.end));
      if (!constant && str_quoted->quote_mark()) str_quoted->quote_mark('*');
      str_quoted->is_delayed(true);
      return str_quoted;
    }
    String_Schema* schema = SASS_MEMORY_NEW(ctx.mem, String_Schema, pstate);
    while (i < chunk.end) {
      p = find_first_in_interval< exactly<hash_lbrace> >(i, chunk.end);
      if (p) {
        if (i < p) {
          (*schema) << SASS_MEMORY_NEW(ctx.mem, String_Constant, pstate, std::string(i, p));
        }
        if (peek < sequence < optional_spaces, exactly<rbrace> > >(p+2)) { position = p+2;
          css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was ");
        }
        const char* j = skip_over_scopes< exactly<hash_lbrace>, exactly<rbrace> >(p + 2, chunk.end); 
        if (j) { --j;
          Expression* interp_node = Parser::from_token(Token(p+2, j), ctx, pstate).parse_list();
          interp_node->is_interpolant(true);
          (*schema) << interp_node;
          i = j;
        }
        else {
          error("unterminated interpolant inside string constant " + chunk.to_string(), pstate);
        }
      }
      else { 
        if (i < chunk.end) (*schema) << SASS_MEMORY_NEW(ctx.mem, String_Constant, pstate, std::string(i, chunk.end));
        break;
      }
      ++ i;
    }
    return schema;
  }
String * Parser :: parse_interpolated_chunk ( Token chunk , bool constant ) { const char * i = chunk . begin ; const char * p = find_first_in_interval < exactly < hash_lbrace > > ( i , chunk . end ) ; if ( ! p ) { String_Quoted * str_quoted = SASS_MEMORY_NEW ( ctx . mem , String_Quoted , pstate , std :: string ( i , chunk . end ) ) ; if ( ! constant && str_quoted -> quote_mark ( ) ) str_quoted -> quote_mark ( ' ' ) ; str_quoted -> is_delayed ( true ) ; return str_quoted ; } String_Schema * schema = SASS_MEMORY_NEW ( ctx . mem , String_Schema , pstate ) ; while ( i < chunk . end ) { p = find_first_in_interval < exactly < hash_lbrace > > ( i , chunk . end ) ; if ( p ) { if ( i < p ) { ( * schema ) << SASS_MEMORY_NEW ( ctx . mem , String_Constant , pstate , std :: string ( i , p ) ) ; } if ( peek < sequence < optional_spaces , exactly < rbrace > > > ( p + 2 ) ) { position = p + 2 ; css_error ( " " , " " , " " ) ; } const char * j = skip_over_scopes < exactly < hash_lbrace > , exactly < rbrace > > ( p + 2 , chunk . end ) ; if ( j ) { -- j ; Expression * interp_node = Parser :: from_token ( Token ( p + 2 , j ) , ctx , pstate ) . parse_list ( ) ; interp_node -> is_interpolant ( true ) ; ( * schema ) << interp_node ; i = j ; } else { error ( " " + chunk . to_string ( ) , pstate ) ; } } else { if ( i < chunk . end ) ( * schema ) << SASS_MEMORY_NEW ( ctx . mem , String_Constant , pstate , std :: string ( i , chunk . end ) ) ; break ; } ++ i ; } return schema ; }
this parses interpolation inside other strings
means the result should later be quoted again
this parses interpolation inside other strings means the result should later be quoted again
// see if there any interpolants // accumulate the preceding segment if it's nonempty // we need to skip anything inside strings // create a new target in parser/prelexer // find the closing brace // parse the interpolant and accumulate it // throw an error if the interpolant is unterminated // no interpolants left; add the last segment if nonempty // check if we need quotes here (was not sure after merge)