how to parse list of idents

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

how to parse list of idents

Jens Kallup
Hello,

in symbol_def_parameter, i would like to parse:
"parameter identA" and/or
"parameter identA, identB" , ...

But the formular dont differ between space: ' ' and ','
So, Now my question is, how to declare symbol_def_parameter
in correct way?

----%<----

  symbol_def_parameter =
           (symbol_parameter >
           (symbol_alpha) |
          *(symbol_alpha) > qi::char_(',') > symbol_alpha)
          ;

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

   symbol_parameter = no_case["parameter"];


  BOOST_SPIRIT_DEBUG_NODE(symbol_parameter);
  BOOST_SPIRIT_DEBUG_NODE(symbol_def_parameter);

}

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

qi::rule<Iterator, Skipper>
symbol_def_parameter;


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: how to parse list of idents

Mikael Asplund
Instead, perhaps:  symbol_def_parameter =  (symbol_parameter >  (symbol_alpha % qi::char_(','))) ;

  /Mikael

-----Original Message-----
From: Jens Kallup [mailto:[hidden email]]
Sent: Thursday, October 27, 2016 15:48
To: Spirit General Mailing List <[hidden email]>
Subject: [Spirit-general] how to parse list of idents

Hello,

in symbol_def_parameter, i would like to parse:
"parameter identA" and/or
"parameter identA, identB" , ...

But the formular dont differ between space: ' ' and ','
So, Now my question is, how to declare symbol_def_parameter in correct way?

----%<----

  symbol_def_parameter =
           (symbol_parameter >
           (symbol_alpha) |
          *(symbol_alpha) > qi::char_(',') > symbol_alpha)
          ;

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

   symbol_parameter = no_case["parameter"];


  BOOST_SPIRIT_DEBUG_NODE(symbol_parameter);
  BOOST_SPIRIT_DEBUG_NODE(symbol_def_parameter);

}

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

qi::rule<Iterator, Skipper>
symbol_def_parameter;


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general

------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: how to parse list of idents

Jens Kallup
Hello Mikael,

Thank You for your fast posting!
It does not work.

Here a snippet of the grammar:

              symsbols =
                    (symbol_def_parameter)
                      |
                  (((symbol_class > symbol_alpha >
                     symbol_of    > symbol_alpha > symbol_endclass >>
run_app) |
                    (symbol_class > symbol_alpha >
                     symbol_of    > symbol_alpha > symbol_endclass)
                    )              |
                  ((symbol_alpha  > qi::char_('=') > expression >>
run_app) |
                   (symbol_alpha  > qi::char_('=') > expression         ))
                  )
                  ;

              symbol_class     = no_case["class"];
              symbol_of        = no_case["of"];
              symbol_endclass  = no_case["endclass"];
              symbol_parameter = no_case["parameter"];

             symbol_def_parameter =
                   (symbol_parameter > (symbol_alpha % qi::char_(',')))
                   ;

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

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

On 10/27/2016 04:19 PM, Mikael Asplund wrote:
> (symbol_parameter >  (symbol_alpha % qi::char_(','))) ;


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive.
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general