Chain.parse constructor

  1. String chain

Parses a string representation of a stack chain.

If chain is the output of a call to Chain.toString, it will be parsed as a full stack chain. Otherwise, it will be parsed as in Trace.parse and returned as a single-trace chain.


factory Chain.parse(String chain) {
  if (chain.isEmpty) return Chain([]);
  if (chain.contains(vmChainGap)) {
    return Chain(chain
        .where((line) => line.isNotEmpty)
  if (!chain.contains(chainGap)) return Chain([Trace.parse(chain)]);

  return Chain(chain.split(chainGap).map(Trace.parseFriendly));