public void Trace(string expr, object value, string path)
{
if (string.IsNullOrEmpty(expr))
{
Store(path, value);
return;
}
int i = expr.IndexOf(';');
string atom = i >= 0 ? expr.Substring(0, i) : expr;
string tail = i >= 0 ? expr.Substring(i + 1) : string.Empty;
if (value != null && _system.HasMember(value, atom))
{
Trace(tail, Index(value, atom), path + ";" + atom);
}
else if (atom == "*")
{
Walk(atom, tail, value, path, WalkWild);
}
else if (atom == "..")
{
Trace(tail, value, path);
Walk(atom, tail, value, path, WalkTree);
}
else if (atom.Length > 2 && atom[0] == '(' && atom[atom.Length - 1] == ')') // [(exp)]
{
Trace(_eval(atom, value, path.Substring(path.LastIndexOf(';') + 1)) + ";" + tail, value, path);
}
else if (atom.Length > 3 && atom[0] == '?' && atom[1] == '(' && atom[atom.Length - 1] == ')') // [?(exp)]
{
Walk(atom, tail, value, path, WalkFiltered);
}
else if (RegExp(@"^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$").IsMatch(atom))
// [start:end:step] Phyton slice syntax
{
Slice(atom, tail, value, path);
}
else if (atom.IndexOf(',') >= 0) // [name1,name2,...]
{
foreach (string part in RegExp(@"'?,'?").Split(atom))
Trace(part + ";" + tail, value, path);
}
}