4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 Lisp::Lisp(LispType newtype)
34 // resources should be on parser obstack, so no need to delete anything
38 Lisp::get_lisp(const char* name) const
40 for(const Lisp* p = this; p != 0; p = p->get_cdr()) {
41 const Lisp* child = p->get_car();
42 if(!child || child->get_type() != TYPE_CONS)
44 const Lisp* childname = child->get_car();
47 std::string childName;
48 if(!childname->get(childName))
50 if(childName == name) {
51 return child->get_cdr();
59 Lisp::print(int indent) const
61 for(int i = 0; i < indent; ++i)
64 if(type == TYPE_CONS) {
66 const Lisp* lisp = this;
69 lisp->v.cons.car->print(indent + 1);
70 lisp = lisp->v.cons.cdr;
72 for(int i = 0; i < indent; ++i)
76 if(type == TYPE_STRING) {
77 printf("'%s' ", v.string);
79 if(type == TYPE_INTEGER) {
80 printf("%d", v.integer);
82 if(type == TYPE_REAL) {
85 if(type == TYPE_SYMBOL) {
86 printf("%s ", v.string);
88 if(type == TYPE_BOOLEAN) {
89 printf("%s ", v.boolean ? "true" : "false");
94 } // end of namespace lisp