X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flisp%2Fparser.hpp;h=47c4fcdf453880dedfbb0d89a59cabd0a7f48e2f;hb=d794aac09d4a3b3f5f93985cd74381bb4de4ce84;hp=b6d02092bd8fb9510484b210e2be919f6c5fa67d;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/lisp/parser.hpp b/src/lisp/parser.hpp index b6d02092b..47c4fcdf4 100644 --- a/src/lisp/parser.hpp +++ b/src/lisp/parser.hpp @@ -1,12 +1,10 @@ -// $Id$ -// // SuperTux // Copyright (C) 2006 Matthias Braun // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,24 +12,24 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_LISP_PARSER_HPP +#define HEADER_SUPERTUX_LISP_PARSER_HPP -#ifndef __LISPPARSER_H__ -#define __LISPPARSER_H__ +#include -#include -#include "lexer.hpp" +#include "lisp/lexer.hpp" -namespace TinyGetText { +namespace tinygettext { class Dictionary; class DictionaryManager; } -namespace lisp -{ +namespace lisp { class Lisp; +class LispFile; class Parser { @@ -39,19 +37,40 @@ public: Parser(bool translate = true); ~Parser(); - Lisp* parse(const std::string& filename); - Lisp* parse(std::istream& stream); + /** + * Parses a lispfile and returns the s-expression structure. + * Note that all memory is held by the parser so don't destroy the parser + * before you are finished with the lisp tree + */ + const Lisp* parse(const std::string& filename); + /** + * Same as parse but reads from a generic std::istream. The sourcename is + * used for errormessages to indicate the source of the data. + */ + const Lisp* parse(std::istream& stream, const std::string& sourcename); + +private: + void parse_error(const char* msg) const __attribute__((__noreturn__)); + const Lisp* read(); + private: - Lisp* read(); - Lexer* lexer; - TinyGetText::DictionaryManager* dictionary_manager; - TinyGetText::Dictionary* dictionary; + std::string filename; + tinygettext::DictionaryManager* dictionary_manager; + tinygettext::Dictionary* dictionary; Lexer::TokenType token; + char** searchpath; + + struct obstack obst; + +private: + Parser(const Parser&); + Parser & operator=(const Parser&); }; } // end of namespace lisp #endif +/* EOF */