endless loop - crashing application

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

endless loop - crashing application

Jens Kallup
Hello,

I have a Problem with boost spirit:

https://github.com/paule32/dBase/blob/master/source/parser/dbase/yymain.cc

the application produce infinite loop and crash after few steps in line 102.
I have no idea, where I can look for.
Please have look onto the Link above these Post.

I would like parse: "varident = 2"  or "varident = 2 + 1 + 3" ...

TIA - Thank In Advice for helping hand


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Joel de Guzman
On 19/08/2016 11:14 PM, Jens Kallup wrote:

> Hello,
>
> I have a Problem with boost spirit:
>
> https://github.com/paule32/dBase/blob/master/source/parser/dbase/yymain.cc
>
> the application produce infinite loop and crash after few steps in line 102.
> I have no idea, where I can look for.
> Please have look onto the Link above these Post.
>
> I would like parse: "varident = 2"  or "varident = 2 + 1 + 3" ...

I'm getting a 404. Did you move the repository?

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/21/2016 01:04 PM, Joel de Guzman wrote:

> On 19/08/2016 11:14 PM, Jens Kallup wrote:
>> Hello,
>>
>> I have a Problem with boost spirit:
>>
>> https://github.com/paule32/dBase/blob/master/source/parser/dbase/yymain.cc
>>
>> the application produce infinite loop and crash after few steps in line 102.
>> I have no idea, where I can look for.
>> Please have look onto the Link above these Post.
>>
>> I would like parse: "varident = 2"  or "varident = 2 + 1 + 3" ...
>
> I'm getting a 404. Did you move the repository?
>
I'm guessing yes, to here:

https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/21/2016 01:32 PM, Larry Evans wrote:

> On 08/21/2016 01:04 PM, Joel de Guzman wrote:
>> On 19/08/2016 11:14 PM, Jens Kallup wrote:
>>> Hello,
>>>
>>> I have a Problem with boost spirit:
>>>
>>> https://github.com/paule32/dBase/blob/master/source/parser/dbase/yymain.cc
>>>
>>> the application produce infinite loop and crash after few steps in line 102.
>>> I have no idea, where I can look for.
>>> Please have look onto the Link above these Post.
>>>
>>> I would like parse: "varident = 2"  or "varident = 2 + 1 + 3" ...
>>
>> I'm getting a 404. Did you move the repository?
>>
> I'm guessing yes, to here:
>
> https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc
>
However, even after cloning that, compilation failed:

--{--cute here--
install -d `dirname
/tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o`
/home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++
-c -O0 -stdlib=libc++  -std=c++14 -ftemplate-backtrace-limit=0
-fdiagnostics-show-template-tree -fno-elide-type
-fmacro-backtrace-limit=0
-I/home/evansl/prog_dev/boost/releases/ro/boost_1_59_0
-ftemplate-depth=100  yymain.cc -MMD -o
/tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o

yymain.cc:1:10: fatal error: '../../../prech.h' file not found
#include "../../../prech.h"
          ^
1 error generated.
/home/evansl/prog_dev/root.imk:180: recipe for target
'/tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o'
failed
make: ***
[/tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o]
Error 1
make: Target 'o' not remade because of errors.

Compilation exited abnormally with code 2 at Sun Aug 21 14:13:21
--}--cute here--

Jens, could you upload the missing files to make it compilable?
Also, you mentioned the application producing an infinite loop.
However, yymain.cc has no main function; hence, it's not runable,
AFAICT. Could you also supply the main function?

-regards,
Larry




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Jens Kallup
Hello,

sorry for the misadvantages.
The code has changed, but don't run, yet.

Here:
https://github.com/paule32/dBase4Linux

you can find the Qt5 Project under new ReproName.

https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc
is the location of file of interesst.

I get these Error's:

https://paste.fedoraproject.org/412112/71805678/

I only would like "compile", and "interpret" the string: "value = 2"
As next step: "value = 2 + 1 * 4"

The #include file in first line of yymain.cc is a "pre compiled header"
which you can
use with g++ to minimize the compile time.
It is binary code, and consume over 600 MegaByte's of disk space.

The file in Line 3 is a Qt5 custom header (for my GUI Project).
Each of them can be removed and/or commented in source.

The rest should be speak for it self.
Here have a look to line 422 - there is the line/point where I would
like to start.

Hope it Helps

Jens

------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/21/2016 03:11 PM, Jens Kallup wrote:

> Hello,
>
> sorry for the misadvantages.
> The code has changed, but don't run, yet.
>
> Here:
> https://github.com/paule32/dBase4Linux
>
> you can find the Qt5 Project under new ReproName.
>
> https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc
> is the location of file of interesst.
>
> I get these Error's:
>
> https://paste.fedoraproject.org/412112/71805678/
>
> I only would like "compile", and "interpret" the string: "value = 2"
> As next step: "value = 2 + 1 * 4"
>
> The #include file in first line of yymain.cc is a "pre compiled header"
> which you can
> use with g++ to minimize the compile time.
> It is binary code, and consume over 600 MegaByte's of disk space.
>
> The file in Line 3 is a Qt5 custom header (for my GUI Project).
> Each of them can be removed and/or commented in source.

Yes, that helped; however, I'm still getting errors for, I guess,
Qt5 symbols:

/home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++
-c -O0 -stdlib=libc++  -std=c++14 -ftemplate-backtrace-limit=0
-fdiagnostics-show-template-tree -fno-elide-type
-fmacro-backtrace-limit=0
-I/home/evansl/prog_dev/boost/releases/ro/boost_1_59_0
-ftemplate-depth=100  yymain.cc -MMD -o
/tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o

yymain.cc:495:20: error: unknown type name 'QString'
bool InitParseText(QString text)
                    ^
yymain.cc:499:9: error: use of undeclared identifier 'QMessageBox'
         QMessageBox::information(0,"Error","No Data for parser.\nABORT.");
         ^

Please provide the compiler command line showing the -I flags.

-regards,
Larry



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/21/2016 03:42 PM, Larry Evans wrote:

> On 08/21/2016 03:11 PM, Jens Kallup wrote:
>> Hello,
>>
>> sorry for the misadvantages.
>> The code has changed, but don't run, yet.
>>
>> Here:
>> https://github.com/paule32/dBase4Linux
>>
>> you can find the Qt5 Project under new ReproName.
>>
>> https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc
>> is the location of file of interesst.
>>
>> I get these Error's:
>>
>> https://paste.fedoraproject.org/412112/71805678/
>>
>> I only would like "compile", and "interpret" the string: "value = 2"
>> As next step: "value = 2 + 1 * 4"
>>
>> The #include file in first line of yymain.cc is a "pre compiled header"
>> which you can
>> use with g++ to minimize the compile time.
>> It is binary code, and consume over 600 MegaByte's of disk space.
>>
>> The file in Line 3 is a Qt5 custom header (for my GUI Project).
>> Each of them can be removed and/or commented in source.
>
> Yes, that helped; however, I'm still getting errors for, I guess,
> Qt5 symbols:
>
> /home/evansl/dwnlds/llvm/3.8/prebuilt/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-14.04/bin/clang++
> -c -O0 -stdlib=libc++  -std=c++14 -ftemplate-backtrace-limit=0
> -fdiagnostics-show-template-tree -fno-elide-type
> -fmacro-backtrace-limit=0
> -I/home/evansl/prog_dev/boost/releases/ro/boost_1_59_0
> -ftemplate-depth=100  yymain.cc -MMD -o
> /tmp/build/clangxx3_8_pkg/boost/github/paul32/dBase4Linux/source/parser/dbase/yymain.o
>
> yymain.cc:495:20: error: unknown type name 'QString'
> bool InitParseText(QString text)
>                     ^
> yymain.cc:499:9: error: use of undeclared identifier 'QMessageBox'
>          QMessageBox::information(0,"Error","No Data for parser.\nABORT.");
>          ^
>
> Please provide the compiler command line showing the -I flags.
>
Better yet, just strip out everything having to do with qt or any
library other that what's needed for spirit.

I think this is the standard practice for people asking for help
here.  I know it's extra trouble for you, OTOH, not doing it
makes extra trouble for people trying to help you ;)

-regards,
Larry




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Joel de Guzman
On 22/08/2016 5:12 AM, Larry Evans wrote:

> Better yet, just strip out everything having to do with qt or any
> library other that what's needed for spirit.
>
> I think this is the standard practice for people asking for help
> here.  I know it's extra trouble for you, OTOH, not doing it
> makes extra trouble for people trying to help you ;)

I second that. Here's the support policy FYI:
http://boost-spirit.com/home/feedback-and-support/

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Jens Kallup
In reply to this post by cppljevans
Hello,

QString, and QMessageBox are library functions from Qt.
QString is the equalivant of std::string.

I have change the source, so it should be compiled with
STL.
Thanks for helping
Jens

#define BOOST_SPIRIT_USE_PHOENIX_V3
#define BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT

#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/karma.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/std_pair.hpp>
#include <boost/variant/recursive_variant.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/get.hpp>

#include <boost/algorithm/string.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/lexical_cast.hpp>

#include <boost/bind.hpp>
#include <boost/ref.hpp>

#include <iostream>
#include <fstream>
#include <string>
#include <typeinfo>
#include <set>
#include <utility>
#include <vector>

int lineno = 1;


using namespace std;
using namespace boost::spirit;

namespace bs    = boost::spirit;
namespace phx   = boost::phoenix;
namespace ascii = boost::spirit::ascii;

using boost::spirit::ascii::space; // use the ASCII space parser
using boost::spirit::ascii::char_;
using boost::spirit::_val;

using boost::phoenix::val;

namespace dBaseParser
{
     // -----------------
     // AST for dBase ...
     // -----------------
     struct binary_op;
     struct unary_op;
     struct nil { };
     //struct dBaseExpression;
     struct class_op;

     typedef boost::variant<
           std::string
         , double
     > dBaseVariant;
     std::map<std::string,dBaseVariant> dynamics;

     int backend = 0;
     int tmp_value_int = 0;

     enum dBaseTypes {
         unknown,
         m_value,
         c_value
     };
     dBaseTypes dBaseType;

     struct expression_ast
     {
         typedef
         boost::variant<
               nil
             , int
             , double
             , dBaseTypes
             , std::string
             , boost::recursive_wrapper<expression_ast>
             , boost::recursive_wrapper<binary_op>
             , boost::recursive_wrapper<unary_op>
             , boost::recursive_wrapper<class_op>
            // , boost::recursive_wrapper<dBaseExpression>
         >
         type;
         type expr;

         template <typename Expr>
         expression_ast(Expr const & expr)
             : expr(expr) {  }

         expression_ast() {}
         expression_ast(
                   std::string const& name
                 , std::string const& str1
                 , std::string const& str2
                 , expression_ast const& rhs);

         expression_ast(expression_ast const & rhs, std::string const & name);

         expression_ast& operator += (expression_ast const & rhs);
         expression_ast& operator -= (expression_ast const & rhs);
         expression_ast& operator *= (expression_ast const & rhs);
         expression_ast& operator /= (expression_ast const & rhs);
     };

     expression_ast dast;

     struct binary_op
     {
         binary_op(
               char op
             , expression_ast const & left
             , expression_ast const & right)
             : op(op)
             , left(left)
             , right(right)
         {
             std::cout << "Math2: " << std::endl;
         }

         char op;
         expression_ast left;
         expression_ast right;
     };
     struct unary_op
     {
         unary_op(
             char op
           , expression_ast const& subject)
         : op(op), subject(subject) {}

         char op;
         expression_ast subject;
     };

     struct class_op
     {
         class_op(
               std::string const& op
             , std::string const& cname
             , std::string const& oname
             , expression_ast const& left
             , expression_ast const& right)
             : op(op)
             , class_cname(cname)
             , class_oname(oname)
             , left(left)
             , right(right) { }

         std::string op;
         std::string class_cname;
         std::string class_oname;

         expression_ast left;
         expression_ast right;
     };


     expression_ast::expression_ast(expression_ast const & rhs, std::string const & name)
     {
         cout << "dinit" << endl;
         cout << name << endl;
         cout << rhs.expr.type().name() << endl;

         expr = rhs;
     }

     expression_ast::expression_ast  (
               std::string const& name
             , std::string const& str1
             , std::string const& str2, expression_ast const& rhs)
     {
         expr = class_op(name, str1, str2, *this, rhs);
     }

     expression_ast& expression_ast::operator += (expression_ast const& rhs)
     {
         expr = binary_op('+', expr, rhs);
         return *this;
     }

     expression_ast& expression_ast::operator -= (expression_ast const& rhs)
     {
         expr = binary_op('-', expr, rhs);
         return *this;
     }

     expression_ast& expression_ast::operator *= (expression_ast const& rhs)
     {
         expr = binary_op('*', expr, rhs);
         return *this;
     }

     expression_ast& expression_ast::operator /= (expression_ast const& rhs)
     {
         expr = binary_op('/', expr, rhs);
         return *this;
     }

     // We should be using expression_ast::operator-. There's a bug
     // in phoenix type deduction mechanism that prevents us from
     // doing so. Phoenix will be switching to BOOST_TYPEOF. In the
     // meantime, we will use a phoenix::function below:
     struct negate_expr
     {
         template <typename T>
         struct result { typedef T type; };

         expression_ast operator()(expression_ast & expr) const
         {
             cout << "lllllllllllllllll\n";
             return expression_ast(unary_op('-', expr));
         }
     };

     phx::function<negate_expr> neg;

     struct __addnumber
     {
         template <typename T>
         struct result { typedef T type; };

         expression_ast operator()(expression_ast const &_expr, std::string &namber) const
         {
             cout << "scene: " << endl;

             //dast = int(1);

             cout << "add number ok." << endl;

             //cout << _expr.expr.type().name() << endl;
             return expression_ast(int(1)); //binary_op('+', _expr, _expr));
         }
     };

     phx::function<__addnumber> _addnumber;

     // -----------------------
     // walk throug the AST ...
     // -----------------------
     struct ast_print
     {
         typedef void result_type;

         void operator()(int const value)
         {
             cout << "const int = " << value << endl;
             dast = value;
             cout << dast.expr.type().name() << endl;
         }

         void operator()(expression_ast const& ast) const
         {
             //if (!(ast.expr.type().name() == std::string("N11dBaseParser3nilE")))
             boost::apply_visitor(*this, ast.expr);
         }

         void operator()(binary_op const& expr) const
         {
             std::cout << "op:" << expr.op << "(";
             boost::apply_visitor(*this, expr.left.expr);
             std::cout << ", ";
             boost::apply_visitor(*this, expr.right.expr);
             std::cout << ')';
         }

         void operator()(unary_op const& expr) const
         {
             std::cout << "op:" << expr.op << "(";
             boost::apply_visitor(*this, expr.subject.expr);
             std::cout << ')';
         }

         void operator()(class_op const& expr) const
         {
             std::cout << "class:"
                       << expr.class_cname << ":"
                       << expr.class_oname
                       << "(null)"
                       << std::endl;
             boost::apply_visitor(*this, expr.left.expr);
         }
     };

     template <typename Lexer>
     struct dbase_tokens : lex::lexer<Lexer>
     {
         // ----------------------------
         // tokens with no attributes...
         // ----------------------------
         lex::token_def<lex::omit> whitespace;
         lex::token_def<lex::omit> cpcomment;
         lex::token_def<lex::omit> d_comment;
         lex::token_def<lex::omit> c_comment;

         lex::token_def<lex::omit> kw_class;
         lex::token_def<lex::omit> kw_of;
         lex::token_def<lex::omit> kw_endclass;

         // --------------------------
         // tokens with attributes ...
         // --------------------------
         lex::token_def<char> printLn;
         lex::token_def<lex::omit> my_assign;

         lex::token_def<int>         number_digit;
         lex::token_def<std::string> identifier;
         lex::token_def<std::string> quoted_string;

         dbase_tokens()
         {
             // ------------
             // keywords ...
             // ------------
             kw_class        = "(?i:class)";
             kw_endclass     = "(?i:endclass)";
             kw_of           = "(?i:of)";

             printLn   = "\\\?";
             my_assign = "\\=";

             // Values.
             number_digit      = "[0-9]*";
             quoted_string     = "\\\"(\\\\.|[^\\\"])*\\\"";

             // Identifier.
             identifier        = "[a-zA-Z][a-zA-Z0-9_]*";

             cpcomment = "\\/\\/[^\\n]*\\n";                    // single line comment
             d_comment = "\\*\\*[^\\n]*\\n";                    // dBase  line comment
             c_comment = "\\/\\*[^*]*\\*+([^/*][^*]*\\*+)*\\/"; // c-style comments

             whitespace = "[ \\t\\n]+";

             this->self += lex::token_def<>
                     ('(') | ')'
                     | '+' | '-'
                     | '*' | '/'
                     | ',' | '.';
             this->self +=
                 printLn
                 ;
             this->self +=
                 kw_class | kw_of | kw_endclass
                 ;
             this->self +=
                   identifier
                 | my_assign
                 | number_digit
                 | quoted_string
                 ;

             this->self +=
                   whitespace [ lex::_pass = lex::pass_flags::pass_ignore ]
                 | cpcomment
                 | c_comment
                 | d_comment
                 ;
         }
     };

     template <typename Iterator, typename Lexer>
     struct dbase_grammar
     :   public qi::grammar<Iterator>
     {   template <typename TokenDef>

         dbase_grammar(TokenDef const& tok) :
         dbase_grammar::base_type(start, "start")
         {
             using qi::_val;

             start
                 = +symsbols
                 ;

             expression =
                 term                            [ _val  = qi::_1 ]
                 >> *(   ('+' >> term            [ _val += qi::_1 ])
                     |   ('-' >> term            [ _val -= qi::_1 ])
                     )
                 ;

             term =
                 factor                          [ _val  = qi::_1]
                 >> *(   ('*' >> factor          [ _val *= qi::_1])
                     |   ('/' >> factor          [ _val /= qi::_1])
                     )
                 ;

             factor =
                 tok.number_digit                [ _val = qi::_1 ]
                 |  '('   >> expression          [ _val = qi::_1 ] >> ')'
                 |   ('-' >> factor              [ _val = neg(qi::_1)])
                 |   ('+' >> factor              [ _val = qi::_1 ] )
                 ;

             symsbols
                 = printLn
                 | comments
                 | class_definition
                 | h_expression
                 ;

             h_expression
                 = (tok.identifier   >> *comments
                 >> tok.my_assign    >> *comments
                 >> tok.number_digit >> *comments
                    [
                      _val = _addnumber(qi::_1,std::string("blub"))

                      ///phx::construct<expression_ast>(qi::_1,
                      ///std::string("exprrr"))

                    ] )
                 ;

             comments
                 = tok.cpcomment
                 | tok.c_comment
                 | tok.d_comment
                 ;

             printLn
                 = tok.printLn >> *comments >> tok.quoted_string
                 | tok.printLn >>              tok.quoted_string
                 ;

             class_definition
                 =   (  tok.kw_class      >> *comments
                     >> tok.identifier    >> *comments
                     >> tok.kw_of         >> *comments
                     >> tok.identifier    >> *comments >> class_body
                     >> tok.kw_endclass)
                     [
                         qi::_val = phx::construct<expression_ast>(
                              std::string("class")
                             , "qi::_1"
                             , "qi::_2", qi::_val)
                     ]
                 ;
             class_body
                 = *comments
                 ;

             start.name("start");
             symsbols.name("symsbols");
             comments.name("comments");
             expression.name("expression");
             term.name("term");
             factor.name("factor");
             printLn.name("printLn");
             class_definition.name("class_definition");
             class_body.name("class_body");
             h_expression.name("h_expression");
/*
             BOOST_SPIRIT_DEBUG_NODE(start);
             BOOST_SPIRIT_DEBUG_NODE(symsbols);
             BOOST_SPIRIT_DEBUG_NODE(comments);
             BOOST_SPIRIT_DEBUG_NODE(printLn);
             BOOST_SPIRIT_DEBUG_NODE(class_definition);
             BOOST_SPIRIT_DEBUG_NODE(class_body);
             BOOST_SPIRIT_DEBUG_NODE(factor);
             BOOST_SPIRIT_DEBUG_NODE(term);
             BOOST_SPIRIT_DEBUG_NODE(expression);
             BOOST_SPIRIT_DEBUG_NODE(h_expression);
                     */
         }

         typedef qi::unused_type skipper_type;
         typedef qi::rule<Iterator, skipper_type> simple_rule;

         simple_rule start, symsbols, comments, printLn;
         simple_rule class_body;

         qi::rule<Iterator, expression_ast()>
              expression, term, factor
            , h_expression
            , class_definition;
     };
}

bool InitParseText(std::string text)
{
     std::string data(text);
     if (data.size() < 1) {
         std::cout << "Error: No data for parser." << std::endl;
         return false;
     }

     using dBaseParser::expression_ast;
     using dBaseParser::ast_print;

     typedef std::string::iterator base_iterator_type;
     typedef lex::lexertl::token<
         base_iterator_type, boost::mpl::vector<char, int, std::size_t, std::string>
     > token_type;
     typedef lex::lexertl::actor_lexer<token_type> lexer_type;

     typedef dBaseParser::dbase_tokens<lexer_type> dbase_tokens;
     typedef dbase_tokens::iterator_type iterator_type;
     typedef dBaseParser::dbase_grammar<iterator_type, dbase_tokens::lexer_def> dbase_grammar;

     dbase_tokens  tokens;
     dbase_grammar dbase(tokens);

     base_iterator_type it = data.begin();
     iterator_type iter    = tokens.begin(it, data.end());
     iterator_type end     = tokens.end();

     expression_ast ast;
     return qi::parse(iter, end, dbase, ast);
}

bool parseText(std::string text, int mode)
{
     dBaseParser::ast_print  printer;
     text = "value = 2";

     if (InitParseText(text)) {
         std::cout << "SUCCESS" << std::endl;
         printer(dBaseParser::dast); } else {
         std::cout << "ERROR" << std::endl;
     }

     return true;
}



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Joel de Guzman
On 22/08/2016 1:09 PM, Jens Kallup wrote:
> Hello,
>
> QString, and QMessageBox are library functions from Qt.
> QString is the equalivant of std::string.
>
> I have change the source, so it should be compiled with
> STL.
> Thanks for helping

Before anything else, have you tried BOOST_SPIRIT_DEBUG to
see a trace where the infinite recursion happens? I suspect
left recursive rules.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/22/2016 04:04 AM, Joel de Guzman wrote:

> On 22/08/2016 1:09 PM, Jens Kallup wrote:
>> Hello,
>>
>> QString, and QMessageBox are library functions from Qt.
>> QString is the equalivant of std::string.
>>
>> I have change the source, so it should be compiled with
>> STL.
>> Thanks for helping
>
> Before anything else, have you tried BOOST_SPIRIT_DEBUG to
> see a trace where the infinite recursion happens? I suspect
> left recursive rules.
>
> Regards,
>
Hi Joel,

I tried that; however, the problem I encountered was not at
run-time (which I guess is what BOOST_SPIRIT_DEBUG helps with)
but at compile_time where, with the code posted by Jens in his
last email, results in errors about too many template instantiations:

--{--cut here--
yymain.email2016-08-22_0009.cc:525:32:   required from here
/home/evansl/prog_dev/boost/releases/ro/boost_1_61_0/boost/core/enable_if.hpp:41:10:
fatal error: template instantiation depth exceeds maximum of 100 (use
-ftemplate-depth= to increase the maximum)
    struct enable_if : public enable_if_c<Cond::value, T> {};
           ^
compilation terminated.
--}-- cut here--

Deciphering why this happening from the *huge* compiler error
messages is daunting :(

HTH.

-regards,
Larry



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/22/2016 06:46 AM, Larry Evans wrote:

> On 08/22/2016 04:04 AM, Joel de Guzman wrote:
>> On 22/08/2016 1:09 PM, Jens Kallup wrote:
>>> Hello,
>>>
>>> QString, and QMessageBox are library functions from Qt.
>>> QString is the equalivant of std::string.
>>>
>>> I have change the source, so it should be compiled with
>>> STL.
>>> Thanks for helping
>>
>> Before anything else, have you tried BOOST_SPIRIT_DEBUG to
>> see a trace where the infinite recursion happens? I suspect
>> left recursive rules.
>>
>> Regards,
>>
> Hi Joel,
>
> I tried that; however, the problem I encountered was not at
> run-time (which I guess is what BOOST_SPIRIT_DEBUG helps with)
> but at compile_time where, with the code posted by Jens in his
> last email, results in errors about too many template instantiations:
>
> --{--cut here--
> yymain.email2016-08-22_0009.cc:525:32:   required from here
> /home/evansl/prog_dev/boost/releases/ro/boost_1_61_0/boost/core/enable_if.hpp:41:10:
> fatal error: template instantiation depth exceeds maximum of 100 (use
> -ftemplate-depth= to increase the maximum)
>     struct enable_if : public enable_if_c<Cond::value, T> {};
>            ^
> compilation terminated.
> --}-- cut here--
>
> Deciphering why this happening from the *huge* compiler error
> messages is daunting :(

Cutting out some of the rule definitions until there was just factor
avoided in 'excceeds maximum' error message.  IOW:

--{--cut here--
#define CUT_RULES 1
#if CUT_RULES
   #define CUT_EXPRESSION 1
   #if CUT_EXPRESSION
   #else
              expression =
                  factor                            [ _val  = qi::_1 ]
                  >> *(   ('+' >> factor            [ _val += qi::_1 ])
                      |   ('-' >> factor            [ _val -= qi::_1 ])
                      )
                  ;
   #endif //CUT_EXPRESSION
              factor =
                  tok.number_digit                [ _val = qi::_1 ]
                  |   ('-' >> factor              [ _val = neg(qi::_1)])
                  |   ('+' >> factor              [ _val = qi::_1 ] )
                  ;
#else
//as before
#endif //CUT_RULES
--}--cut here--

compiles, but with #define CUT_EXPRESSION 0, compilation fails with
the 'excceeds maximum' error message.

-regards,
Larry






------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Jens Kallup
In reply to this post by cppljevans
Hello,

the problem is in template line 100.
It seems that " : expr(expr)"
is the point

Jens

------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/22/2016 07:35 AM, Jens Kallup wrote:

> Hello,
>
> the problem is in template line 100.
> It seems that " : expr(expr)"
> is the point
>
> Jens
>
> ------------------------------------------------------------------------------
>
Please be more specific.
Why not put a yymain_debug.cc and a Makefile in your repository
so we can see exactly what you're doing?

-regards,
Larry



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
In reply to this post by cppljevans
On 08/22/2016 07:25 AM, Larry Evans wrote:

> On 08/22/2016 06:46 AM, Larry Evans wrote:
>> On 08/22/2016 04:04 AM, Joel de Guzman wrote:
>>> On 22/08/2016 1:09 PM, Jens Kallup wrote:
>>>> Hello,
>>>>
>>>> QString, and QMessageBox are library functions from Qt.
>>>> QString is the equalivant of std::string.
>>>>
>>>> I have change the source, so it should be compiled with
>>>> STL.
>>>> Thanks for helping
>>>
>>> Before anything else, have you tried BOOST_SPIRIT_DEBUG to
>>> see a trace where the infinite recursion happens? I suspect
>>> left recursive rules.
>>>
>>> Regards,
>>>
>> Hi Joel,
>>
>> I tried that; however, the problem I encountered was not at
>> run-time (which I guess is what BOOST_SPIRIT_DEBUG helps with)
>> but at compile_time where, with the code posted by Jens in his
>> last email, results in errors about too many template instantiations:
>>
>> --{--cut here--
>> yymain.email2016-08-22_0009.cc:525:32:   required from here
>> /home/evansl/prog_dev/boost/releases/ro/boost_1_61_0/boost/core/enable_if.hpp:41:10:
>> fatal error: template instantiation depth exceeds maximum of 100 (use
>> -ftemplate-depth= to increase the maximum)
>>     struct enable_if : public enable_if_c<Cond::value, T> {};
>>            ^
>> compilation terminated.
>> --}-- cut here--
>>
>> Deciphering why this happening from the *huge* compiler error
>> messages is daunting :(
>
> Cutting out some of the rule definitions until there was just factor
> avoided in 'excceeds maximum' error message.  IOW:
>
> --{--cut here--
> #define CUT_RULES 1
> #if CUT_RULES
>    #define CUT_EXPRESSION 1
>    #if CUT_EXPRESSION
>    #else
>               expression =
>                   factor                            [ _val  = qi::_1 ]
>                   >> *(   ('+' >> factor            [ _val += qi::_1 ])
>                       |   ('-' >> factor            [ _val -= qi::_1 ])
>                       )
>                   ;
>    #endif //CUT_EXPRESSION
>               factor =
>                   tok.number_digit                [ _val = qi::_1 ]
>                   |   ('-' >> factor              [ _val = neg(qi::_1)])
>                   |   ('+' >> factor              [ _val = qi::_1 ] )
>                   ;
> #else
> //as before
> #endif //CUT_RULES
> --}--cut here--
>
> compiles, but with #define CUT_EXPRESSION 0, compilation fails with
> the 'excceeds maximum' error message.
>
> -regards,
> Larry
The source and compilation output are now here:

https://github.com/cppljevans/boost_sandbox/tree/master/paul32



------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Jens Kallup
Hello Larry,

check out this:

https://paste.fedoraproject.org/412461/47187367/

TIA
Jens

Am 22.08.2016 um 15:32 schrieb Larry Evans:
>> -regards,
>> >Larry
> The source and compilation output are now here:
>
> https://github.com/cppljevans/boost_sandbox/tree/master/paul32


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/22/2016 08:50 AM, Jens Kallup wrote:

> Hello Larry,
>
> check out this:
>
> https://paste.fedoraproject.org/412461/47187367/
>
> TIA
> Jens
>
> Am 22.08.2016 um 15:32 schrieb Larry Evans:
>>> -regards,
>>>> Larry
>> The source and compilation output are now here:
>>
>> https://github.com/cppljevans/boost_sandbox/tree/master/paul32
>
>
> ------------------------------------------------------------------------------
>
Ah.  Thank you!  I just had too small value for -ftemplate-depth.

Now compilation succeeds; however, the code still has no main.
How to you run it without a main function?

-Larry




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
On 08/22/2016 09:15 AM, Larry Evans wrote:

> On 08/22/2016 08:50 AM, Jens Kallup wrote:
>> Hello Larry,
>>
>> check out this:
>>
>> https://paste.fedoraproject.org/412461/47187367/
>>
>> TIA
>> Jens
>>
>> Am 22.08.2016 um 15:32 schrieb Larry Evans:
>>>> -regards,
>>>>> Larry
>>> The source and compilation output are now here:
>>>
>>> https://github.com/cppljevans/boost_sandbox/tree/master/paul32
>>
>>
>> ------------------------------------------------------------------------------
>>
> Ah.  Thank you!  I just had too small value for -ftemplate-depth.
>
> Now compilation succeeds; however, the code still has no main.
> How to you run it without a main function?
>
It succeeded OK, but that was because:
   #define CUT_EXPRESSION 1
when code changed to *not* skip any rule definitions, compilation failed
as shown in updated files here:

https://github.com/cppljevans/boost_sandbox/tree/master/paul32

Still trying to figure out why.

-Larry




------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

cppljevans
In reply to this post by Jens Kallup
On 08/22/2016 08:50 AM, Jens Kallup wrote:
> Hello Larry,
>
> check out this:
>
> https://paste.fedoraproject.org/412461/47187367/
>
> TIA
> Jens
>
After constifying the 2nd arg to expression_ast::add_number, it compiled
with just warnings and #pragma messages.

Is your problem solved?

-regards,
Larry





------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: endless loop - crashing application

Jens Kallup
Hello Larry,

I have luck with compiling, too.
I have refactoring the code to an old message of Poster.
You can see the forwards here:

https://github.com/paule32/dBase4Linux/blob/master/source/parser/dbase/yymain.cc

Now, it work.

TIA
Jens

Am 22.08.2016 um 19:09 schrieb Larry Evans:
>
> After constifying the 2nd arg to expression_ast::add_number, it compiled
> with just warnings and #pragma messages.
>
> Is your problem solved?
>
> -regards,
> Larry
>

------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
12