|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73116 - in trunk/libs/spirit/example/qi/compiler_tutorial: conjure1 conjure2 mini_c
From: joel_at_[hidden]
Date: 2011-07-14 22:51:20
Author: djowel
Date: 2011-07-14 22:51:18 EDT (Thu, 14 Jul 2011)
New Revision: 73116
URL: http://svn.boost.org/trac/boost/changeset/73116
Log:
Removing extra prints
Text files modified:
trunk/libs/spirit/example/qi/compiler_tutorial/conjure1/compiler.cpp | 8 --------
trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp | 16 ++++------------
trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp | 16 ++++++----------
trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/compiler.cpp | 8 --------
4 files changed, 10 insertions(+), 38 deletions(-)
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure1/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure1/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure1/compiler.cpp 2011-07-14 22:51:18 EDT (Thu, 14 Jul 2011)
@@ -237,7 +237,6 @@
int const* p = current->find_var(x.name);
if (p == 0)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "Undeclared variable: " + x.name);
return false;
}
@@ -290,7 +289,6 @@
if (functions.find(x.function_name.name) == functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Function not found: " + x.function_name.name);
return false;
}
@@ -299,7 +297,6 @@
if (p->nargs() != x.args.size())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Wrong number of arguments: " + x.function_name.name);
return false;
}
@@ -432,7 +429,6 @@
int const* p = current->find_var(x.lhs.name);
if (p == 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Undeclared variable: " + x.lhs.name);
return false;
}
@@ -446,7 +442,6 @@
int const* p = current->find_var(x.lhs.name);
if (p != 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Duplicate variable: " + x.lhs.name);
return false;
}
@@ -530,7 +525,6 @@
{
if (x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "'void' function returning a value: ");
return false;
}
@@ -539,7 +533,6 @@
{
if (!x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, current_function_name + " function must return a value: ");
return false;
}
@@ -559,7 +552,6 @@
void_return = x.return_type == "void";
if (functions.find(x.function_name.name) != functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Duplicate function: " + x.function_name.name);
return false;
}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure2/compiler.cpp 2011-07-14 22:51:18 EDT (Thu, 14 Jul 2011)
@@ -238,7 +238,6 @@
int const* p = current->find_var(x.name);
if (p == 0)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "Undeclared variable: " + x.name);
return false;
}
@@ -291,7 +290,6 @@
if (functions.find(x.function_name.name) == functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Function not found: " + x.function_name.name);
return false;
}
@@ -300,7 +298,6 @@
if (p->nargs() != x.args.size())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Wrong number of arguments: " + x.function_name.name);
return false;
}
@@ -391,7 +388,7 @@
};
}
- inline int get_precedence(ast::optoken op)
+ inline int precedence_of(ast::optoken op)
{
return precedence[op & ~ast::op_mask];
}
@@ -402,17 +399,17 @@
std::list<ast::operation>::const_iterator& rbegin,
std::list<ast::operation>::const_iterator rend)
{
- while ((rbegin != rend) && (get_precedence(rbegin->operator_) >= min_precedence))
+ while ((rbegin != rend) && (precedence_of(rbegin->operator_) >= min_precedence))
{
ast::optoken op = rbegin->operator_;
if (!boost::apply_visitor(*this, rbegin->operand_))
return false;
++rbegin;
- while ((rbegin != rend) && (get_precedence(rbegin->operator_) > get_precedence(op)))
+ while ((rbegin != rend) && (precedence_of(rbegin->operator_) > precedence_of(op)))
{
ast::optoken next_op = rbegin->operator_;
- compile_expression(get_precedence(next_op), rbegin, rend);
+ compile_expression(precedence_of(next_op), rbegin, rend);
}
(*this)(op);
}
@@ -438,7 +435,6 @@
int const* p = current->find_var(x.lhs.name);
if (p == 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Undeclared variable: " + x.lhs.name);
return false;
}
@@ -452,7 +448,6 @@
int const* p = current->find_var(x.lhs.name);
if (p != 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Duplicate variable: " + x.lhs.name);
return false;
}
@@ -536,7 +531,6 @@
{
if (x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "'void' function returning a value: ");
return false;
}
@@ -545,7 +539,6 @@
{
if (!x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, current_function_name + " function must return a value: ");
return false;
}
@@ -565,7 +558,6 @@
void_return = x.return_type == "void";
if (functions.find(x.function_name.name) != functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Duplicate function: " + x.function_name.name);
return false;
}
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/annotation.hpp 2011-07-14 22:51:18 EDT (Thu, 14 Jul 2011)
@@ -37,24 +37,20 @@
int id;
set_id(int id) : id(id) {}
- template <typename T>
- void operator()(T& x) const
+ void operator()(ast::function_call& x) const
{
- this->dispatch(x, boost::is_base_of<ast::tagged, T>());
+ x.function_name.id = id;
}
- // This will catch all nodes except those inheriting from ast::tagged
- template <typename T>
- void dispatch(T& x, boost::mpl::false_) const
+ void operator()(ast::identifier& x) const
{
- // (no-op) no need for tags
+ x.id = id;
}
- // This will catch all nodes inheriting from ast::tagged
template <typename T>
- void dispatch(T& x, boost::mpl::true_) const
+ void operator()(T& x) const
{
- x.id = id;
+ // no-op
}
};
Modified: trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/mini_c/compiler.cpp 2011-07-14 22:51:18 EDT (Thu, 14 Jul 2011)
@@ -237,7 +237,6 @@
int const* p = current->find_var(x.name);
if (p == 0)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "Undeclared variable: " + x.name);
return false;
}
@@ -292,7 +291,6 @@
if (functions.find(x.function_name.name) == functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Function not found: " + x.function_name.name);
return false;
}
@@ -301,7 +299,6 @@
if (p->nargs() != x.args.size())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Wrong number of arguments: " + x.function_name.name);
return false;
}
@@ -342,7 +339,6 @@
int const* p = current->find_var(x.lhs.name);
if (p == 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Undeclared variable: " + x.lhs.name);
return false;
}
@@ -356,7 +352,6 @@
int const* p = current->find_var(x.lhs.name);
if (p != 0)
{
- std::cout << x.lhs.id << std::endl;
error_handler(x.lhs.id, "Duplicate variable: " + x.lhs.name);
return false;
}
@@ -440,7 +435,6 @@
{
if (x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, "'void' function returning a value: ");
return false;
}
@@ -449,7 +443,6 @@
{
if (!x.expr)
{
- std::cout << x.id << std::endl;
error_handler(x.id, current_function_name + " function must return a value: ");
return false;
}
@@ -469,7 +462,6 @@
void_return = x.return_type == "void";
if (functions.find(x.function_name.name) != functions.end())
{
- std::cout << x.function_name.id << std::endl;
error_handler(x.function_name.id, "Duplicate function: " + x.function_name.name);
return false;
}
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