Beispiel #1
0
        public static Symbol get_symbol(string name, out bool was_defined)
        {
            Symbol sym;

            was_defined = symbol_world.TryGetValue(name, out sym);

            if (!was_defined) {
                sym = new Symbol(name);
                symbol_world.Add(name, sym);
            }

            return sym;
        }
Beispiel #2
0
        public object lookup(TxtLocation loc, Symbol sym)
        {
            object def;

            if (definitions.TryGetValue(sym, out def)) {
                return def;
            } else if (m_parent != null) {
                return m_parent.lookup(loc, sym);
            } else if (m_trap(sym, out def)) {
                return def;
            } else {
                throw new InterpreterException(loc, sym.name + " is undefined");
            }
        }
Beispiel #3
0
 public static string get_abbrev(Symbol sym)
 {
     if (sym == quote) {
         return "'";
     } else if (sym == quasiquotation) {
         return "`";
     } else if (sym == unquote) {
         return ",";
     } else if (sym == unquote_splicing) {
         return ",@";
     } else {
         return null;
     }
 }
Beispiel #4
0
 public void visit_value(Symbol s)
 {
     scount++;
 }
Beispiel #5
0
 private bool GetSymbol(string name, out Symbol symbol) =>
     symbols.TryGetValue(name, out symbol);
Beispiel #6
0
 public override void visit(Symbol o)
 {
     if (m_atom != null) m_atom.visit(o);
 }
Beispiel #7
0
        bool write_abbrev(Symbol sym)
        {
            string abbrev = Abbrev.get_abbrev(sym);

            if (abbrev != null) {
                m_writer.Append(abbrev);
                return true;
            } else {
                return false;
            }
        }
Beispiel #8
0
 static bool no_trap(Symbol sym, out object def)
 {
     def = null;
     return false;
 }
Beispiel #9
0
 public void AddMacro(Symbol sym, SpecialForm.Macro m)
 {
     definitions.Add(sym, new SpecialForm(m));
 }
Beispiel #10
0
 public void AddFn(Symbol sym, Closure.Fn fn)
 {
     definitions.Add(sym, new Closure(fn));
 }
Beispiel #11
0
 public void Add(Symbol sym, object def)
 {
     definitions.Add(sym, def);
 }
Beispiel #12
0
 public override void visit(Symbol o)
 {
     base.visit(o);
     m_print.print(outbox);
 }
Beispiel #13
0
 public override void visit(Symbol o)
 {
     outbox.put(m_env.lookup(m_loc, o));
 }
Beispiel #14
0
 public virtual void visit(Symbol o)
 {
     visit((object)o);
 }