public static SExpression Parse(this string code) { var program = new SExpression("", null); var current = program; foreach(var lex in Tokenizer.Tokenize(code)) { if(lex == "(") { var node = new SExpression("(", current); current.Children.Add(node); current = node; } else if(lex == ")") { current = current.Parent; } else { current.Children.Add(new SExpression(lex, current)); } } return program.Children[0]; }
public SFunction(SExpression body, string[] parameters, SScope scope) { Body = body; Parameters = parameters; Scope = scope; }
public SExpression(string value, SExpression parent) { Value = value; Children = new List <SExpression>(); Parent = parent; }
public SExpression(string value, SExpression parent) { Value = value; Children = new List<SExpression>(); Parent = parent; }