Quantcast

rule.h:177:13 error_invalid_expression

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

rule.h:177:13 error_invalid_expression

Jens Kallup
Hello,

I can't find the error in this snippet code:
It is copy&paste from my original code,
but I get "error_invalid_expression"
Can you help?

Thank You
Jens


     struct error
     {
         template <typename A, typename B = unused_type, typename C =
unused_type>
         struct result { typedef void type; };

         error() { }
         void operator()(const std::string &msg) const {
             std::cout << "MyError: " << msg << std::endl;
             _pass = false;
             throw msg;
         }
     };

     template <typename Iterator, typename Skipper =
dbase_skipper<Iterator>>
     struct dbase_grammar : public qi::grammar<Iterator, Skipper>
     {
         qi::rule<Iterator, Skipper> start;
         dbase_grammar()  : dbase_grammar::base_type(start)
         {
             using boost::spirit::ascii::no_case;

             using qi::lit;
             using qi::char_;
             using qi::lexeme;

             using qi::on_error;
             using qi::fail;

             start = symsbols;

             symsbols %=
                 (symbol_def_expr)
                 ;


             qualified_id %= symbol_alpha >> *('.' > symbol_alpha);
             variable      = qualified_id;

             symbol_expr  %=
             (
                 (variable | int_ | double_ )
             >> *(
                     (('+' | '-' | '*' | '/') > symbol_expr)
                 )
             )
             ;

             symbol_def_expr %=
             (
                 ((variable > char_('=')) > symbol_expr) |
                 ( variable
                 >> *(
                         (eol | eoi | variable | int_ | double_ )
                         > eps[
                             my_error(
                                 std::string("Syntax error: variable can
not standalone!")
                             )
                         ]
                     )
                 )
             )
             ;

             symbol_space =
                  +(qi::char_(" \t\n\r") | eol | eoi)
                  ;

             symbol_alpha %=
                   qi::char_("a-zA-Z_") >>
                 *(qi::char_("a-zA-Z0-9_"))
                 ;

              symbol_digit =
                  +(qi::digit)
                  ;

             symbol_if        = lexeme[no_case["if"]];
             symbol_of        = lexeme[no_case["of"]];
             symbol_new       = lexeme[no_case["new"]];
             symbol_else      = lexeme[no_case["else"]];
             symbol_class     = lexeme[no_case["class"]];
             symbol_endif     = lexeme[no_case["endif"]];
             symbol_local     = lexeme[no_case["local"]];
             symbol_return    = lexeme[no_case["return"]];
             symbol_endclass  = lexeme[no_case["endclass"]];
             symbol_function  = lexeme[no_case["function"]];
             symbol_parameter = lexeme[no_case["parameter"]];
             symbol_procedure = lexeme[no_case["procedure"]];

             qi::on_error<fail>( start, client::error_handler(_4, _3, _2) );
         }

         qi::rule<Iterator, Skipper> assignment_rhs;
         qi::rule<Iterator, Skipper>
                  equality_expr, relational_expr
                , logical_expr, additive_expr, multiplicative_expr
                , unary_expr, primary_expr, variable, symbol_expr,
qualified_id
                ;

          boost::phoenix::function<compile_op> op;
          boost::phoenix::function<error     > my_error;

          qi::rule<Iterator, std::string()>
          symbol_alpha,
          symbol_ident;

          qi::rule<Iterator, Skipper>
          symsbols, skipp_keywords,
          symbol_local,
          symbol_if,
          symbol_else,
          symbol_endif,
          symbol_digit,
          symbol_space,
          symbol_class,
          symbol_endclass,
          symbol_of,
          symbol_new,
          symbol_parameter, symbol_def_string,
          symbol_procedure, symbol_function, symbol_proc_stmts,
symbol_return,

          symbol_def_expr,
          symbol_def_parameter,
          symbol_def_procedure, symbol_def_function, symbol_def_return,
          symbol_def_if,
          symbol_def_if_inner,
          symbol_def_stmts,
          symbol_def_stmts_rep,
          symbol_def_local,
          symbol_def_class_inner,
          symbol_def_class;

          qi::rule<Iterator, Skipper> expression, term, factor;

          qi::rule<Iterator, std::string(), Skipper, qi::locals<char> >
quoted_string, any_string;
      };


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

Re: rule.h:177:13 error_invalid_expression

sehe
On 30-11-16 18:55, Jens Kallup wrote:
> It is copy&paste from my original code,
> but I get "error_invalid_expression"
> Can you help?

You know better than this by now. One man can pose more questions than
10 can answer.

Please at least make the sample self-contained. That way you might even
trap your own copy/paste errors.

Don't expect to hear from me again until you do - I'm already sorry for
spending time yesterday (to which you haven't even responded).

I'm hereby stamping you "help vampire". I can assume the best
intentions, and I even give you the benefit of the doubt with a possible
language barrier, but right now the sheer volume of questions and the
lack of improvement in them leave me no other conclusion.

Seth


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