Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81092 - trunk/libs/spirit/example/qi/compiler_tutorial/conjure2
From: joel_at_[hidden]
Date: 2012-10-28 22:05:15


Author: djowel
Date: 2012-10-28 22:05:14 EDT (Sun, 28 Oct 2012)
New Revision: 81092
URL: http://svn.boost.org/trac/boost/changeset/81092

Log:
Patch from Michele Bertasi fixing segmentation fault bug
Text files modified:
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/error_handler.hpp | 14 ++++++++++----
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/main.cpp | 1 +
   2 files changed, 11 insertions(+), 4 deletions(-)

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/error_handler.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/error_handler.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/error_handler.hpp 2012-10-28 22:05:14 EDT (Sun, 28 Oct 2012)
@@ -36,12 +36,18 @@
             // to the last validly matched token, so we use its end iterator
             // as the error position
             BaseIterator err_pos_base = err_pos->matched().end();
-
+ std::cout << message << what << std::endl;
+ if (err_pos_base != BaseIterator())
+ dump_error_line(err_pos_base);
+ }
+
+ void dump_error_line(BaseIterator err_pos_base) const
+ {
             int line;
             BaseIterator line_start = get_pos(err_pos_base, line);
             if (err_pos_base != last)
             {
- std::cout << message << what << " line " << line << ':' << std::endl;
+ std::cout << " line " << line << ':' << std::endl;
                 std::cout << get_line(line_start) << std::endl;
                 for (; line_start != err_pos_base; ++line_start)
                     std::cout << ' ';
@@ -49,9 +55,9 @@
             }
             else
             {
- std::cout << "Unexpected end of file. ";
- std::cout << message << what << " line " << line << std::endl;
+ std::cout << "Unexpected end of file.\n";
             }
+
         }
 
         BaseIterator get_pos(BaseIterator err_pos, int& line) const

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/main.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/main.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/main.cpp 2012-10-28 22:05:14 EDT (Sun, 28 Oct 2012)
@@ -122,6 +122,7 @@
     }
     else
     {
+ error_handler.dump_error_line(first);
         std::cout << "Parse failure\n";
     }
     return 0;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk