I am trying the Second Answer of this question. The parsing itself works fine, but after uncommenting the #define BOOST_SPIRIT_DEBUG
on the first line, the BOOST_SPIRIT_DEBUG
output still does not appear anywhere.
When I add these 3 lines below to the main()
, I am seeing all 3 lines appear in my terminal. However, I don't see any parser debug lines. What is missing?
std::cout << "Hello cout" << std::endl;
std::cerr << "Hello cerr" << std::endl;
BOOST_SPIRIT_DEBUG_OUT << "Hello boost spirit debug out" << std::endl;
Probably worth mentioning I am using Qt Creator.
I cannot reproduce this:
#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/qi.hpp>
int main() {
std::cout << "Hello cout" << std::endl;
std::cerr << "Hello cerr" << std::endl;
BOOST_SPIRIT_DEBUG_OUT << "Hello boost spirit debug out" << std::endl;
}
Prints
Hello cout
Hello cerr
Hello boost spirit debug out
So all the usual culprits are:
Here's that linked second answer demo Live On Coliru with debug output (or without):
<expr_>
<try>-99</try>
<function_call_>
<try>-99</try>
<fail/>
</function_call_>
<value_>
<try>-99</try>
<success></success>
<attributes>[-99]</attributes>
</value_>
<success></success>
<attributes>[-99]</attributes>
</expr_>
input: -99
eval: -99
<expr_>
<try>'string'</try>
<function_call_>
<try>'string'</try>
<fail/>
</function_call_>
<value_>
<try>'string'</try>
<string_>
<try>'string'</try>
<success></success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</string_>
<success></success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</value_>
<success></success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</expr_>
input: 'string'
eval: string
<expr_>
<try>AnswerToLTUAE()</try>
<function_call_>
<try>AnswerToLTUAE()</try>
<success></success>
<attributes>[42]</attributes>
</function_call_>
<success></success>
<attributes>[42]</attributes>
</expr_>
input: AnswerToLTUAE()
eval: 42
<expr_>
<try>ReverseString('strin</try>
<function_call_>
<try>ReverseString('strin</try>
<expr_>
<try>'string')</try>
<function_call_>
<try>'string')</try>
<fail/>
</function_call_>
<value_>
<try>'string')</try>
<string_>
<try>'string')</try>
<success>)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</string_>
<success>)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</value_>
<success>)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</expr_>
<success></success>
<attributes>[[g, n, i, r, t, s]]</attributes>
</function_call_>
<success></success>
<attributes>[[g, n, i, r, t, s]]</attributes>
</expr_>
input: ReverseString('string')
eval: gnirts
<expr_>
<try>Concatenate('string'</try>
<function_call_>
<try>Concatenate('string'</try>
<expr_>
<try>'string', 987)</try>
<function_call_>
<try>'string', 987)</try>
<fail/>
</function_call_>
<value_>
<try>'string', 987)</try>
<string_>
<try>'string', 987)</try>
<success>, 987)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</string_>
<success>, 987)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</value_>
<success>, 987)</success>
<attributes>[[s, t, r, i, n, g]]</attributes>
</expr_>
<expr_>
<try> 987)</try>
<function_call_>
<try> 987)</try>
<fail/>
</function_call_>
<value_>
<try> 987)</try>
<success>)</success>
<attributes>[987]</attributes>
</value_>
<success>)</success>
<attributes>[987]</attributes>
</expr_>
<success></success>
<attributes>[[s, t, r, i, n, g, 9, 8, 7]]</attributes>
</function_call_>
<success></success>
<attributes>[[s, t, r, i, n, g, 9, 8, 7]]</attributes>
</expr_>
input: Concatenate('string', 987)
eval: string987
<expr_>
<try>Concatenate('The Ans</try>
<function_call_>
<try>Concatenate('The Ans</try>
<expr_>
<try>'The Answer Is ', An</try>
<function_call_>
<try>'The Answer Is ', An</try>
<fail/>
</function_call_>
<value_>
<try>'The Answer Is ', An</try>
<string_>
<try>'The Answer Is ', An</try>
<success>, AnswerToLTUAE())</success>
<attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, ]]</attributes>
</string_>
<success>, AnswerToLTUAE())</success>
<attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, ]]</attributes>
</value_>
<success>, AnswerToLTUAE())</success>
<attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, ]]</attributes>
</expr_>
<expr_>
<try> AnswerToLTUAE())</try>
<function_call_>
<try> AnswerToLTUAE())</try>
<success>)</success>
<attributes>[42]</attributes>
</function_call_>
<success>)</success>
<attributes>[42]</attributes>
</expr_>
<success></success>
<attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, , 4, 2]]</attributes>
</function_call_>
<success></success>
<attributes>[[T, h, e, , A, n, s, w, e, r, , I, s, , 4, 2]]</attributes>
</expr_>
input: Concatenate('The Answer Is ', AnswerToLTUAE())
eval: The Answer Is 42