mail[Wesnoth-commits] r28721 - in /trunk/src/serialization: parser.cpp tokenizer.cpp tokenizer.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by paniemin on August 18, 2008 - 18:31:
Author: suokko
Date: Mon Aug 18 18:31:27 2008
New Revision: 28721

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28721&view=rev
Log:
Made parser to add currently handled text to error message when throwing error

Modified:
    trunk/src/serialization/parser.cpp
    trunk/src/serialization/tokenizer.cpp
    trunk/src/serialization/tokenizer.hpp

Modified: trunk/src/serialization/parser.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/parser.cpp?rev=28721&r1=28720&r2=28721&view=diff
==============================================================================
--- trunk/src/serialization/parser.cpp (original)
+++ trunk/src/serialization/parser.cpp Mon Aug 18 18:31:27 2008
@@ -334,10 +334,17 @@
 {
        utils::string_map i18n_symbols;
        i18n_symbols["error"] = error_type;
-
+       i18n_symbols["value"] = tok_->current_token().value;
+#ifdef DEBUG
+       i18n_symbols["previous_value"] = tok_->previous_token().value;
        throw config::error(
                lineno_string(i18n_symbols, tok_->get_line(),
-                             N_("$error at $pos")));
+                             N_("$error, value '$value', previous 
'$previous_value' at $pos")));
+#else
+       throw config::error(
+               lineno_string(i18n_symbols, tok_->get_line(),
+                             N_("$error, value '$value' at $pos")));
+#endif
 }
 
 } // end anon namespace

Modified: trunk/src/serialization/tokenizer.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/tokenizer.cpp?rev=28721&r1=28720&r2=28721&view=diff
==============================================================================
--- trunk/src/serialization/tokenizer.cpp (original)
+++ trunk/src/serialization/tokenizer.cpp Mon Aug 18 18:31:27 2008
@@ -118,8 +118,10 @@
 
 const token& tokenizer::next_token()
 {
-       token_.value = "";
-       token_.leading_spaces = "";
+#if DEBUG
+       previous_token_ = token_;
+#endif
+       token_.reset();
 
        // Dump spaces and inlined comments
        for(;;) {
@@ -196,6 +198,12 @@
        return token_;
 }
 
+#ifdef DEBUG
+const token& tokenizer::previous_token() const
+{
+       return previous_token_;
+}
+#endif
 
 bool tokenizer::is_space(const int c) const
 {

Modified: trunk/src/serialization/tokenizer.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/tokenizer.hpp?rev=28721&r1=28720&r2=28721&view=diff
==============================================================================
--- trunk/src/serialization/tokenizer.hpp (original)
+++ trunk/src/serialization/tokenizer.hpp Mon Aug 18 18:31:27 2008
@@ -50,6 +50,11 @@
                END
        } type;
 
+       void reset() {
+               leading_spaces = "";
+               value = "";
+       }
+
        std::string leading_spaces;
        std::string value;
 };
@@ -63,6 +68,9 @@
 
        const token& next_token();
        const token& current_token() const;
+#ifdef DEBUG
+       const token& previous_token() const;
+#endif
        std::string get_line() const;
        std::string& textdomain();
 
@@ -124,6 +132,9 @@
        std::string file_;
        size_t tokenstart_lineno_;
        token token_;
+#ifdef DEBUG
+       token previous_token_;
+#endif
        std::istream& in_;
 };
 




Related Messages


Powered by MHonArc, Updated Mon Aug 18 20:02:08 2008