boost-spirit

Boost.Qi rule with skipper does not match '.' character

痞子三分冷 提交于 2021-02-19 23:09:33
问题 So I have the following qi skipper: template<typename Iterator> struct verilog_skipper : public qi::grammar<Iterator> { verilog_skipper() : verilog_skipper::base_type(skip) { namespace phx = boost::phoenix; skip = qi::ascii::space | qi::eol | line_comment; line_comment = (qi::lit("//") >> *(qi::char_ - qi::eol) >> *(qi::eol)); } qi::rule<Iterator> skip; qi::rule<Iterator> line_comment; }; and the following qi grammar: template <typename Iterator, typename Skipper = verilog_skipper<Iterator>

Boost.Qi rule with skipper does not match '.' character

Deadly 提交于 2021-02-19 23:06:59
问题 So I have the following qi skipper: template<typename Iterator> struct verilog_skipper : public qi::grammar<Iterator> { verilog_skipper() : verilog_skipper::base_type(skip) { namespace phx = boost::phoenix; skip = qi::ascii::space | qi::eol | line_comment; line_comment = (qi::lit("//") >> *(qi::char_ - qi::eol) >> *(qi::eol)); } qi::rule<Iterator> skip; qi::rule<Iterator> line_comment; }; and the following qi grammar: template <typename Iterator, typename Skipper = verilog_skipper<Iterator>

Boost Spirit: parse boolean expression and reduce to canonical normal form

眉间皱痕 提交于 2021-02-19 08:21:21
问题 I want to parse a common Boolean with just or , and and not operators, which I think I have done using Boost Spirit below. In phase 2 (or perhaps part of the parsing itself), I wish to transform the AST of the Boolean to disjunctive canonical normal form, which essentially "flattens" the expression and removes all grouping operators. In one of my attempts, I created the Boost static_visitor below, named Transformer . I started by trying to eliminate double not operators by just assigning a

Boost Spirit: parse boolean expression and reduce to canonical normal form

狂风中的少年 提交于 2021-02-19 08:21:11
问题 I want to parse a common Boolean with just or , and and not operators, which I think I have done using Boost Spirit below. In phase 2 (or perhaps part of the parsing itself), I wish to transform the AST of the Boolean to disjunctive canonical normal form, which essentially "flattens" the expression and removes all grouping operators. In one of my attempts, I created the Boost static_visitor below, named Transformer . I started by trying to eliminate double not operators by just assigning a

Boost:spirit Parsing into structure and reusing parts of it

对着背影说爱祢 提交于 2021-02-19 07:38:23
问题 I have to find variables in a sentence and replace them by their value. Variables can be written in different forms, like $varName, or $(varName) for example. I'd like to have a struct VariableHolder to have easy access to both : struct VariableHolder { string name; // contains "varName" string fromFile; // contains "$(varName)" or "$varName" void setName(ustring n) { name = n; } } Obviously, I'd like to avoid doing multiple passes and calling multiple parsers. What I have so far is this :

How to parse a grammar into a `std::set` using `boost::spirit`?

耗尽温柔 提交于 2021-02-19 04:20:20
问题 TL;DR How to parse the result of a boost::spirit grammar into an std::set ? Full problem statement As an exercise to learn how to use boost::spirit , I am designing a parser for X.500/LDAP Distinguished Names. The grammar can be found in a BNF format in the RFC-1779. I "unrolled" it and translated it into boost::spirit rules. That's the first step. Basically, a DN is a set of RDN (Relative Distinguished Names) which themselves are tuples of (Key,Value) pairs. I think about using typedef std:

How to parse a grammar into a `std::set` using `boost::spirit`?

陌路散爱 提交于 2021-02-19 04:18:06
问题 TL;DR How to parse the result of a boost::spirit grammar into an std::set ? Full problem statement As an exercise to learn how to use boost::spirit , I am designing a parser for X.500/LDAP Distinguished Names. The grammar can be found in a BNF format in the RFC-1779. I "unrolled" it and translated it into boost::spirit rules. That's the first step. Basically, a DN is a set of RDN (Relative Distinguished Names) which themselves are tuples of (Key,Value) pairs. I think about using typedef std:

Spirit X3, How to get attribute type to match rule type?

為{幸葍}努か 提交于 2021-02-18 17:50:53
问题 For the development of Spirit X3 parser I want to use semantic actions(footnote 1). It is important for me to be in control of how to store attributes into STL containers. This question is about how to control that the parser attribute: _attr( ctx ) match the rule type: _val( ctx ) so that it can be assigned properly. Maybe this question boils down to how to apply the undocumented transform_attribute feature. But please read with me to see if that is actually the thing that solves it for me

How to combine skipping and non-skipping (lexeme) rules?

会有一股神秘感。 提交于 2021-02-13 05:44:54
问题 my parser is nearly working :) (still amazed by Spirit feature set (and compiletimes) and the very welcoming community here on stack overflow) small sample for online try: http://coliru.stacked-crooked.com/a/1c1bf88909dce7e3 so i've learned to use more lexeme-rules and try to prevent no_skip - my rules are smaller and better to read as a result but now i stuck with combining lexeme-rules and skipping-rules what seems to be not possible (compiletime error with warning about not castable to

How to combine skipping and non-skipping (lexeme) rules?

老子叫甜甜 提交于 2021-02-13 05:42:12
问题 my parser is nearly working :) (still amazed by Spirit feature set (and compiletimes) and the very welcoming community here on stack overflow) small sample for online try: http://coliru.stacked-crooked.com/a/1c1bf88909dce7e3 so i've learned to use more lexeme-rules and try to prevent no_skip - my rules are smaller and better to read as a result but now i stuck with combining lexeme-rules and skipping-rules what seems to be not possible (compiletime error with warning about not castable to