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