|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69432 - trunk/libs/spirit/example/qi/compiler_tutorial/calc7
From: joel_at_[hidden]
Date: 2011-02-28 23:13:13
Author: djowel
Date: 2011-02-28 23:13:10 EST (Mon, 28 Feb 2011)
New Revision: 69432
URL: http://svn.boost.org/trac/boost/changeset/69432
Log:
small error reporting tweaks
Text files modified:
trunk/libs/spirit/example/qi/compiler_tutorial/calc7/error_handler.hpp | 18 +++++++++++++-----
trunk/libs/spirit/example/qi/compiler_tutorial/calc7/main.cpp | 5 +++++
2 files changed, 18 insertions(+), 5 deletions(-)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/calc7/error_handler.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/calc7/error_handler.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/calc7/error_handler.hpp 2011-02-28 23:13:10 EST (Mon, 28 Feb 2011)
@@ -33,11 +33,19 @@
{
int line;
Iterator line_start = get_pos(err_pos, line);
- std::cout << message << what << " line " << line << ':' << std::endl;
- std::cout << get_line(line_start) << std::endl;
- for (; line_start != err_pos; ++line_start)
- std::cout << ' ';
- std::cout << '^' << std::endl;
+ if (err_pos != last)
+ {
+ std::cout << message << what << " line " << line << ':' << std::endl;
+ std::cout << get_line(line_start) << std::endl;
+ for (; line_start != err_pos; ++line_start)
+ std::cout << ' ';
+ std::cout << '^' << std::endl;
+ }
+ else
+ {
+ std::cout << "Unexpected end of file. ";
+ std::cout << message << what << " line " << line << std::endl;
+ }
}
Iterator get_pos(Iterator err_pos, int& line) const
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/calc7/main.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/calc7/main.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/calc7/main.cpp 2011-02-28 23:13:10 EST (Mon, 28 Feb 2011)
@@ -33,6 +33,11 @@
std::cout << "/////////////////////////////////////////////////////////\n\n";
std::cout << "Type some statements... ";
std::cout << "An empty line ends input, compiles, runs and prints results\n\n";
+ std::cout << "Example:\n\n";
+ std::cout << " var a = 123;\n";
+ std::cout << " var b = 456;\n";
+ std::cout << " var c = a + b * 2;\n\n";
+ std::cout << "-------------------------\n";
std::string str;
std::string source;
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