string interpolation is complex and it nests, so we do that in here
553480
public function interpString($m)
    {
        // this should only be called for doubly quoted strings
        // and triple-double quotes
        //
        // interpolation is betwee ${ ... }
        $patterns = array('interp' => '/(?<!\\$)\\$\\{/');
        $start = $this->pos();
        if (preg_match('/^"""/', $m[0])) {
            $patterns['term'] = '/"""/';
            $this->posShift(3);
        } else {
            assert(preg_match('/^"/', $m[0]));
            $patterns['term'] = '/"/';
            $this->posShift(1);
        }
        while (1) {
            $p = $this->pos();
            list($name, $index, $matches) = $this->getNextNamed($patterns);
            if ($name === null) {
                // no matches, terminate
                $this->record(substr($this->string(), $start), 'STRING');
                $this->terminate();
                break;
            } elseif ($name === 'term') {
                // end of the string
                $range = $index + strlen($matches[0]);
                $this->record(substr($this->string(), $start, $range - $start), 'STRING');
                $this->pos($range);
                break;
            } else {
                // interpolation, handle this with a subscanner
                $this->record(substr($this->string(), $start, $index - $start), 'STRING');
                $this->record($matches[0], 'DELIMITER');
                $subscanner = new GroovyScanner($this->string());
                $subscanner->interpolation = true;
                $subscanner->init();
                $subscanner->pos($index + strlen($matches[0]));
                $subscanner->main();

                $tagged = $subscanner->tagged();
                $this->record($tagged, 'INTERPOLATION', true);
                $this->pos($subscanner->pos());
                if ($this->scan('/\\}/')) {
                    $this->record($this->match(), 'DELIMITER');
                }
                $start = $this->pos();
            }
            assert($p < $this->pos());
        }
    }
2095
function(str, options = {}) {
    var comment, current, data, lines, stack;
    lines = string.lines(str);
    current = data = {};
    stack = [current];
    comment = options.comment || ';';
    lines.forEach(function(line, _, __) {
      var depth, match, parent;
      if (!line || line.match(/^\s*$/)) {
        return;
      }
      // Category
      if (match = line.match(/^\s*(\[+)(.+?)(\]+)\s*$/)) {
        depth = match[1].length;
        // Add a child
        if (depth === stack.length) {
          parent = stack[depth - 1];
          parent[match[2]] = current = {};
          stack.push(current);
        }
        // Invalid child hierarchy
        if (depth > stack.length) {
          throw Error(`Invalid child ${match[2]}`);
        }
        // Move up or at the same level
        if (depth < stack.length) {
          stack.splice(depth, stack.length - depth);
          parent = stack[depth - 1];
          parent[match[2]] = current = {};
          return stack.push(current);
        }
      // comment
      } else if (comment && (match = line.match(RegExp(`^\\s*(${comment}.*)$`)))) {
        return current[match[1]] = null;
      // key value
      } else if (match = line.match(/^\s*(.+?)\s*=\s*(.+)\s*$/)) {
        return current[match[1]] = match[2];
      // else
      } else if (match = line.match(/^\s*(.+?)\s*$/)) {
        return current[match[1]] = null;
      }
    });
    return data;
  }
737065
function findInterpolation(string, startIndex) {
    const interpolationRegex = /#{(.*?)}/g;
    const results = [];
    // Searching for interpolation
    let match = interpolationRegex.exec(string);

    startIndex = !isNaN(startIndex) ? Number(startIndex) : 0;
    while (match !== null) {
      results.push({
        source: match[0],
        operators: findOperators({
          string: match[0],
          globalIndex: match.index + startIndex
        })
      });
      match = interpolationRegex.exec(string);
    }

    return results;
  }
525218
function nest (str, refs, escape) {
		var res = [], match

		var a = 0
		while (match = re.exec(str)) {
			if (a++ > 10e3) throw Error('Circular references in parenthesis')

			res.push(str.slice(0, match.index))

			res.push(nest(refs[match[1]], refs))

			str = str.slice(match.index + match[0].length)
		}

		res.push(str)

		return res
	}
1170035
function valToString(val, hasSign) {

      var str = "";

      if (Complex && val instanceof Complex) {

        if (val['im'] === 0) {

          if (val['re'] > 0 && hasSign) {
            str += "+";
          }
          str += val['re'];

        } else if (val['re'] === 0) {

          if (val['im'] === -1) {
            str += "-";
          } else if (val['im'] !== 1) {

            if (val['im'] > 0 && hasSign) {
              str += "+";
            }
            str += val['im'];
          } else {
            if (val['im'] > 0 && hasSign) {
              str += "+";
            }
          }
          str += "i";

        } else {

          if (hasSign) {
            str += "+";
          }

          str += "(";
          str += val.toString();
          str += ")";
        }

        return str;

      } else {

        if (val > 0 && hasSign) {
          str += "+";
        }
        str += val.toString();
      }
      return str;
    }
1016062
function interpolation1(prefix, v0, suffix) {
    var different = bindingUpdated(v0);
    return different ? prefix + stringify$1(v0) + suffix : NO_CHANGE;
}
965830
function resemblesData (string) {
  const fixed = ethUtil.addHexPrefix(string)
  const isValidAddress = ethUtil.isValidAddress(fixed)
  return !isValidAddress && isValidHex(string)
}
361460
function(string, strict) {
		if (typeof string !== 'string')
			return string;
		if (cacheFull[string])
			return cacheFull[string];
		var splitted = string.split(splitRegEx);
		if (splitted.length == 1)
			return string; // string is not interpolable
		return cacheFull[string] = new Interpolable(string, splitted, strict);
	}
734752
function(str, index) {
    // replace {{ xxx }}
    var obj = this
    str = str.replace(interpolateReg, function(match, interpolate) {
      try {
        /*jslint evil: true */
        var funcNames = ['','index'].concat(fakerFuncNames).concat(['return ' + interpolate + ';']),
        func = new (Function.prototype.bind.apply(Function, funcNames)),
        funcs = [function(){return index}].concat(fakerFuncs);

        return func.apply(obj, funcs);
        
      } catch(e)  {
        return e.message;
      }
    });

    // if result is true or false, parse it to boolean
    if(/^(true|false)$/.test(str)) {
      str = str === 'true';
    }

    // if result is digit, parse it to float
    if(/^[-+]?\d*\.?\d+$/.test(str)) {
      str = parseFloat(str);
    }

    return str;
  }
1015328
def composition_string
      composition.sort.map do |k, v|
        v == 1 ? k.to_s : "#{k}#{v}"
      end.join('.')
    end
62756
function interpolate (args) {
  var substr = this.match(rtplVars)
  var result = this
  var vars
  var argv

  if (isObject(args)) {
   argv = args
 } else if (Array.isArray(args)) {
   argv = argv = args
  } else if (arguments.length) {
   argv = [].slice.call(arguments)
  }

  if (substr == undefined || !Array.isArray(argv) && !isObject(argv)) {
   return this.toString()
  }

  vars = substr.map(function (str) {
   return str.replace(/(^[$#]\{)|(\}$)/g, '')
  })

  if (isObject(argv) || Array.isArray(argv)) {
   for (var i = 0, len = substr.length; i < len; i++) {
     result = result.replace(substr[i], argv[vars[i]])
   }
  }

  return result
}
901770
def pycomplex(v_str):
    """"""
    assert isinstance(v_str, str)

    if v_str[0] == '(' and v_str[-1] == ')' and len(v_str.split(',')) == 2:
        v_re, v_im = v_str[1:-1].split(',', 1)

        # NOTE: Failed float(str) will raise ValueError
        return complex(pyfloat(v_re), pyfloat(v_im))
    else:
        raise ValueError('{0} must be in complex number form (x, y).'
                         ''.format(v_str))
450654
protected String interpolateString(String value) {
        String interpolatedValue = value;
        for (Map.Entry<String, String> entry : interpolationValues.entrySet()) {
            interpolatedValue = interpolatedValue.replace(entry.getKey(), entry.getValue());
        }

        return interpolatedValue;
    }
1179128
function stringify(x) {
	if (x === Object(x) && x.t === 'MetaString') return x.c;

  var result = [];
  var go = function (key, val) {
    if (key === 'Str') result.push(val);
    else if (key === 'Code') result.push(val[1]);
    else if (key === 'Math') result.push(val[1]);
    else if (key === 'LineBreak') result.push(' ');
    else if (key === 'Space') result.push(' ');
  };
  walk(x, go, '', {});
  return result.join('');
}
281105
function getInterpolation() {
  const type = NodeType.InterpolationType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  let content = [];

  // Skip `#{`:
  pos += 2;

  while (pos < tokensLength &&
      tokens[pos].type !== TokenType.RightCurlyBracket) {
    const body = getArgument();
    if (typeof body.content === 'string') content.push(body);
    else content = content.concat(body);
  }

  const end = getLastPosition(content, line, column, 1);

  // Skip `}`:
  pos++;

  return newNode(type, content, line, column, end);
}
84393
def _process_member(self, member, parent, string):
        """"""
        #The modifiers regex is very greedy so we have some cleaning up to do
        #to extract the mods.
        modifiers = member.group("modifiers")
        dimension = None
        
        if modifiers is not None:
            #Unfortunately, the dimension can also be specified as a modifier and
            #the dimensions can include variable names and functions. This introduces
            #the possibility of nested lists.
            modifiers = modifiers.lower()
            if "dimension" in modifiers:
                start, end = self._get_dim_modifier(modifiers)
                dimension = modifiers[start+1:end]
                dimtext = modifiers[modifiers.index("dimension"):end+1]
                modifiers = re.split(",\s*", modifiers.replace(dimtext, "").strip())
                #modifiers.append("dimension")
            else:
                modifiers = re.split("[,\s]+", modifiers.strip())

            if "" in modifiers:
                modifiers.remove("")

        dtype = member.group("type")
        kind = member.group("kind")
        names = member.group("names")

        #If there are multiple vars defined on this line we need to return
        #a list of all of them.
        result = []

        #They might have defined multiple vars on the same line
        refstring = string[member.start():member.end()].strip()
        if parent is not None:
            refline = parent.module.linenum(member.start())
        else:
            refline = "?"
        ready = self._separate_multiple_def(re.sub(",\s*", ", ", names.strip()), parent, refstring, refline)
        
        for name, ldimension, default, D in self._clean_multiple_def(ready):
            #Now construct the element and set all the values, then add it in the results list.
            udim = ldimension if ldimension is not None else dimension
            uD = D if ldimension is not None else count_dimensions([dimension])
            result.append(ValueElement(name, modifiers, dtype, kind, default, udim, parent, uD))

        return result
766275
def parse_keys(string,
                with_spaces = False,
                with_tabs = False,
                with_newlines = False,
                modifiers = None):
    ""

    keys = []
    if not modifiers:
        modifiers = []
    index = 0
    while index < len(string):

        c = string[index]
        index += 1
        # check if one of CTRL, SHIFT, ALT has been pressed
        if c in MODIFIERS.keys():
            modifier = MODIFIERS[c]
            # remember that we are currently modified
            modifiers.append(modifier)
            # hold down the modifier key
            keys.append(VirtualKeyAction(modifier, up = False))
            if DEBUG:
                print("MODS+", modifiers)
            continue

        # Apply modifiers over a bunch of characters (not just one!)
        elif c == "(":
            # find the end of the bracketed text
            end_pos = string.find(")", index)
            if end_pos == -1:
                raise KeySequenceError('`)` not found')
            keys.extend(
                parse_keys(string[index:end_pos], modifiers = modifiers))
            index = end_pos + 1

        # Escape or named key
        elif c == "{":
            # We start searching from index + 1 to account for the case {}}
            end_pos = string.find("}", index + 1)
            if end_pos == -1:
                raise KeySequenceError('`}` not found')

            code = string[index:end_pos]
            index = end_pos + 1
            keys.extend(handle_code(code))

        # unmatched ")"
        elif c == ')':
            raise KeySequenceError('`)` should be preceeded by `(`')

        # unmatched "}"
        elif c == '}':
            raise KeySequenceError('`}` should be preceeded by `{`')

        # so it is a normal character
        else:
            # don't output white space unless flags to output have been set
            if (c == ' ' and not with_spaces or
                c == '\t' and not with_tabs or
                c == '\n' and not with_newlines):
                continue

            # output nuewline
            if c in ('~', '\n'):
                keys.append(VirtualKeyAction(CODES["ENTER"]))

            # safest are the virtual keys - so if our key is a virtual key
            # use a VirtualKeyAction
            #if ord(c) in CODE_NAMES:
            #    keys.append(VirtualKeyAction(ord(c)))

            elif modifiers:
                keys.append(EscapedKeyAction(c))

            else:
                keys.append(KeyAction(c))

        # as we have handled the text - release the modifiers
        while modifiers:
            if DEBUG:
                print("MODS-", modifiers)
            keys.append(VirtualKeyAction(modifiers.pop(), down = False))

    # just in case there were any modifiers left pressed - release them
    while modifiers:
        keys.append(VirtualKeyAction(modifiers.pop(), down = False))

    return keys