move over rewritten lispreader from tuxkart (with additional fixes), generalized...
[supertux.git] / lib / lisp / list_iterator.h
1 #ifndef __LISP_ITERATOR_H__
2 #define __LISP_ITERATOR_H__
3
4 #include "lisp/lisp.h"
5
6 namespace lisp
7 {
8
9 /**
10  * Small and a bit hacky helper class that helps parsing lisp lists where all
11  * entries are lists again themselves
12  */
13 class ListIterator
14 {
15 public:
16   ListIterator(const lisp::Lisp* cur);
17   
18   const std::string& item() const
19   { return current_item; }
20   lisp::Lisp* lisp() const
21   { return current_lisp; }
22   lisp::Lisp* value() const
23   { return current_lisp->get_car(); }
24   bool next();
25
26 private:
27   std::string current_item;
28   lisp::Lisp* current_lisp;
29   const lisp::Lisp* cur;
30 };
31
32 }
33
34 #endif
35