Updated addon repository URL and improved debug output on download
[supertux.git] / src / lisp / parser.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_LISP_PARSER_HPP
18 #define HEADER_SUPERTUX_LISP_PARSER_HPP
19
20 #include <obstack.h>
21
22 #include "lisp/lexer.hpp"
23
24 namespace tinygettext {
25 class Dictionary;
26 class DictionaryManager;
27 }
28
29 namespace lisp {
30
31 class Lisp;
32 class LispFile;
33
34 class Parser
35 {
36 public:
37   Parser(bool translate = true);
38   ~Parser();
39
40   /**
41    * Parses a lispfile and returns the s-expression structure.
42    * Note that all memory is held by the parser so don't destroy the parser
43    * before you are finished with the lisp tree
44    */
45   const Lisp* parse(const std::string& filename);
46   /**
47    * Same as parse but reads from a generic std::istream. The sourcename is
48    * used for errormessages to indicate the source of the data.
49    */
50   const Lisp* parse(std::istream& stream, const std::string& sourcename);
51
52 private:
53   void parse_error(const char* msg) const __attribute__((__noreturn__));
54   const Lisp* read();
55
56
57 private:
58   Lexer* lexer;
59   std::string filename;
60   tinygettext::DictionaryManager* dictionary_manager;
61   tinygettext::Dictionary* dictionary;
62   Lexer::TokenType token;
63   char** searchpath;
64
65   struct obstack obst;
66
67 private:
68   Parser(const Parser&);
69   Parser & operator=(const Parser&);
70 };
71
72 } // end of namespace lisp
73
74 #endif
75
76 /* EOF */