望ましくない型を出力している Boost Spirit Qi 文法に問題があり、次のコンパイル エラーが発生します。
error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::insert(unsigned int,const std::basic_string<_Elem,_Traits,_Ax> &)' : cannot convert parameter 1 from 'std::_String_iterator<_Elem,_Traits,_Alloc>' to 'unsigned int'
問題の原因となっている文法は次のとおりです。
qi::rule<Iterator, qi::unused_type()> gr_newline;
// asmast::label() just contains an identifier struct that is properly emitted from gr_identifier
qi::rule<Iterator, asmast::label(), skipper<Iterator> > gr_label;
gr_newline = +( char_('\r')
|char_('\n')
);
これは失敗します:
gr_label = gr_identifier
>> ':'
> gr_newline;
ただし、次のすべてが機能します。
// This parses OK
gr_label = gr_identifier
> gr_newline;
// This also parses OK
gr_label = gr_identifier
> ':'
> gr_newline;
// This also parses OK
// **Why does this work when parenthesized?**
gr_label = gr_identifier
>> (':'
> skip_grammar.gr_newline
);
// This also parses OK
gr_label = gr_identifier
>> omit[':'
> gr_newline];
文字リテラルを削除したり、[] を省略したりすると問題が「修正」される理由はわかりませんが、文法がそれで混乱することは望ましくありません。
ここにある>> と > の複合属性規則、およびここにある文字パーサー属性によると、gr_label は asmast::label のみを発行する必要があります。
a: A, b: B --> (a >> b): tuple<A, B>
a: A, b: Unused --> (a >> b): A <---- This one here is the one that should match so far as I understand
a: Unused, b: B --> (a >> b): B
a: Unused, b: Unused --> (a >> b): Unused
Expression Attribute
c unused or if c is a Lazy Argument, the character type returned by invoking it.
ただし、どういうわけか、意図した属性が汚染されており、コンパイラ エラーが発生しています。
したがって、私の質問は、この文法が望ましくない属性をどこで放出するか、およびそれを取り除く方法です。