public SExp ToSExp() { var list = SExp.List(SExp.List("success?", IsSuccess())); if (IsSuccess()) { list.Push( SExp.List("nodes", SExp.List(Nodes?.Select(n => n.ToSExp()).ToArray())), SExp.List("rest", Rest), SExp.List("message", Message), SExp.List("fail_rest", FailRest)); } else { list.Push( SExp.List("message", Message), SExp.List("fail_rest", FailRest), SExp.List("rest", Rest), SExp.List("nodes", SExp.List(Nodes?.Select(n => n.ToSExp()).ToArray()))); } if (!string.IsNullOrEmpty(ParserName)) { list.PushFront(SExp.List(SExp.List("parser", ParserName))); } return(list); }
public ListSExp ToSExp() { if (!IsEmpty()) { var lst = SExp.List(SExp.List( SExp.List("parser", _parser.ToString()), SExp.List("toks", _toks.ToString()))); lst.Append(_prev.ToSExp()); return(lst); } else { return(SExp.List()); } }
public SExp ToSExp() { if (IsLeaf()) { return(SExp.Value(Value)); } else if (TryGetStringValue(out var value)) { var lst = SExp.List(GetNodeMeta()); if (!string.IsNullOrEmpty(value)) { lst.Push(value); } return(lst); } else { var lst = SExp.List(Children.Select(n => n.ToSExp()).ToArray()); lst.PushFront(GetNodeMeta()); return(lst); } }
public ListSExp ToSExp() { return(SExp.List()); }