|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61462 - trunk/libs/spirit/example/scheme/scheme
From: joel_at_[hidden]
Date: 2010-04-21 10:21:09
Author: djowel
Date: 2010-04-21 10:21:08 EDT (Wed, 21 Apr 2010)
New Revision: 61462
URL: http://svn.boost.org/trac/boost/changeset/61462
Log:
More error handling tweaks
Text files modified:
trunk/libs/spirit/example/scheme/scheme/compiler.hpp | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
Modified: trunk/libs/spirit/example/scheme/scheme/compiler.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/scheme/compiler.hpp (original)
+++ trunk/libs/spirit/example/scheme/scheme/compiler.hpp 2010-04-21 10:21:08 EDT (Wed, 21 Apr 2010)
@@ -57,11 +57,11 @@
{
std::string msg;
duplicate_identifier(std::string const& id)
- : msg("scheme: Duplicate identifier (" + id + ')') {}
+ : msg("scheme: Duplicate identifier (" + id + ").") {}
virtual const char* what() const throw()
{
- return "scheme: Duplicate identifier.";
+ return msg.c_str();
}
};
@@ -83,7 +83,22 @@
virtual const char* what() const throw()
{
- return msg.c_str();;
+ return msg.c_str();
+ }
+ };
+
+ struct function_application_expected : scheme_exception
+ {
+ std::string msg;
+ function_application_expected(utree const& got)
+ {
+ // $$$ TODO: add got to message $$$
+ msg = "scheme: Function application expected";
+ }
+
+ virtual const char* what() const throw()
+ {
+ return msg.c_str();
}
};
@@ -245,6 +260,9 @@
template <typename Iterator>
function operator()(boost::iterator_range<Iterator> const& range) const
{
+ if (range.begin()->which() != utree_type::symbol_type)
+ throw function_application_expected(*range.begin());
+
std::string name(get_symbol(*range.begin()));
if (name == "quote")
@@ -329,8 +347,8 @@
throw identifier_not_found(name);
}
- // Just return the list $$$ TODO $$$ how do we disambiguate lists
- // and function calls?
+ // Can't reach here
+ throw compilation_error();
return function();
}
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