Path.parse constructor
Path.parse(
- String path
Construct a Path from string or throw ParseError.
Implementation
factory Path.parse(String path) {
try {
// optimize for common single name case
int dash = path.indexOf('-');
if (dash < 0) return Path1(path);
// parse
int s = 0;
var acc = <String>[];
while (true) {
String n = path.substring(s, dash);
if (n.isEmpty) throw Exception();
acc.add(n);
if (path[dash + 1] != '>') throw Exception();
s = dash + 2;
dash = path.indexOf('-', s);
if (dash < 0) {
n = path.substring(s, path.length);
if (n.isEmpty) throw Exception();
acc.add(n);
break;
}
}
return PathN(path, acc);
} catch (e) {
throw ParseError('Path: $path');
}
}