示例#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;
        }
示例#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");
            }
        }
示例#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;
     }
 }
示例#4
0
 public void visit_value(Symbol s)
 {
     scount++;
 }
示例#5
0
 private bool GetSymbol(string name, out Symbol symbol) =>
     symbols.TryGetValue(name, out symbol);
示例#6
0
 public override void visit(Symbol o)
 {
     if (m_atom != null) m_atom.visit(o);
 }
示例#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;
            }
        }
示例#8
0
 static bool no_trap(Symbol sym, out object def)
 {
     def = null;
     return false;
 }
示例#9
0
 public void AddMacro(Symbol sym, SpecialForm.Macro m)
 {
     definitions.Add(sym, new SpecialForm(m));
 }
示例#10
0
 public void AddFn(Symbol sym, Closure.Fn fn)
 {
     definitions.Add(sym, new Closure(fn));
 }
示例#11
0
 public void Add(Symbol sym, object def)
 {
     definitions.Add(sym, def);
 }
示例#12
0
 public override void visit(Symbol o)
 {
     base.visit(o);
     m_print.print(outbox);
 }
示例#13
0
 public override void visit(Symbol o)
 {
     outbox.put(m_env.lookup(m_loc, o));
 }
示例#14
0
 public virtual void visit(Symbol o)
 {
     visit((object)o);
 }