Exemple #1
0
        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];
        }
Exemple #2
0
 public SFunction(SExpression body, string[] parameters, SScope scope)
 {
     Body       = body;
     Parameters = parameters;
     Scope      = scope;
 }
Exemple #3
0
 public SExpression(string value, SExpression parent)
 {
     Value    = value;
     Children = new List <SExpression>();
     Parent   = parent;
 }
Exemple #4
0
 public SExpression(string value, SExpression parent)
 {
     Value = value;
     Children = new List<SExpression>();
     Parent = parent;
 }