是否可以在另一个语法中重用boost::spirit:qi语法(例如规则)?例如,如果我定义一个语法来将文本行解析为包含街道地址的结构。templatestructaddress_grammar:qi::grammar{...qi::rulestreet_name;qi::rulestreet_number;qi::ruleaddress_;}我可能想在其他两种语法中重用该语法,例如,一种可能用于解析存储在文件中的地址vector。另一种重用可能是更复杂的结构,其中一个字段是这个街道地址结构。templatestructcompany_grammar:qi::grammar{...qi
是否可以在另一个语法中重用boost::spirit:qi语法(例如规则)?例如,如果我定义一个语法来将文本行解析为包含街道地址的结构。templatestructaddress_grammar:qi::grammar{...qi::rulestreet_name;qi::rulestreet_number;qi::ruleaddress_;}我可能想在其他两种语法中重用该语法,例如,一种可能用于解析存储在文件中的地址vector。另一种重用可能是更复杂的结构,其中一个字段是这个街道地址结构。templatestructcompany_grammar:qi::grammar{...qi
我看过一些与qi语法中关键字/标识符使用的细微差别相关的帖子,但我不太明白boost示例中演示的方法应该如何工作......关键字声明:qi::symbolskeywords;示例关键字集:keywords.add("foo")("bar");标识符规则声明:qi::ruleidentifier;以下是qicalc和编译器示例中标识符规则的定义方式:identifier=!keywords>>qi::raw[qi::lexeme[(qi::alpha|'_')>>*(qi::alnum|'_')]];也许我读错了qi语法,但在我看来,这不会接受任何匹配或以关键字开头的文字。拒绝完全关键
我正在解析一个文本文件,可能有几GB的大小,由以下几行组成:110.1140.78532-3.5基本上,每行一个整数和一个float。整数应该是有序的并且是非负的。我想验证数据是否符合描述,并已将范围内的最小和最大整数返回给我。这是我想出的:#include#include#include#include#includenamespacepx=boost::phoenix;namespaceqi=boost::spirit::qi;namespacemy_parsers{usingnamespaceqi;usingpx::at_c;usingpx::val;templatestruct
当尝试将文本解析为boost::variant时,变体的值不会改变。解析器本身似乎工作正常,所以我的假设是我对变体代码做错了什么。我正在使用boost1.46.1和以下代码在VisualStudio2008中编译。第一次更新hkaiser注意到规则和语法模板参数不能是Variant但是Variant().这有点“进一步”,因为我现在在boost_1_46_1\boost\variant\variant.hpp(1304)中有编译错误.评论说://NOTETOUSER://Compileerrorhereindicatesthatthegiventypeisnot//unambiguou
考虑:structs{AttrTypef(conststd::string&);};...和一个带有属性AttrType的规则r:templateusingrule_t=boost::spirit::qi::rule;rule_tr;r=lexeme[alnum>>+(alnum|char_('.')|char_('_'))][_val=boost::phoenix::bind(&s::f,s_inst,_1)];编译时(使用clang),我收到此错误消息:boost/phoenix/bind/detail/preprocessed/member_function_ptr_10.hpp
如果我有一个符号表:structMySymbols:symbols{MySymbols():symbols(std::string("MySymbols")){add("apple",MyEnum::Apple)("orange",MyEnum::Orange);}};我想遍历表格以便按数据值搜索交易品种。我不能使用lambda表达式,所以我实现了一个简单的类:templatestructSymbolSearcher{SymbolSearcher::SymbolSearcher(TsearchFor):_sought(searchFor){//donothing}voidoperato
假设我有一个我想用灵气解析成的结构,它是这样定义的:structdata_{boolexport;std::wstringname;data_():export(false){}};此外,假设结构已适应这样的融合:BOOST_FUSION_ADAPT_STRUCT(data_,(bool,export)(std::wstring,name))关联的规则是:qi::rule>rule_data;rule_data=-lexeme["SpecialText">>!(alnum|'_')][boost::phoenix::at_c=true]//Ifthisstringisfound,,se
我有一个类似于以下的工作语法:stock_price=symbol_>>date_>>price_;stock_prices_=stock_price_>>stock_prices_|eps;grammar_=lit("PRICES")>>stock_prices_>>lit("END");问题是,当股票价格列表太高时(比如大约1000个价格),系统会使用exc_bad_access解析段错误。我实际上可以通过以下方式解决这个问题:stock_prices_=stock_price_>>stock_price_>>stock_price_>>stock_price>>stock_pri
我希望我的基于boost::spirit的解析器能够解析文件,将解析的规则转换为不同的类型,并发出一个包含它找到的所有匹配项的vector。所有作为属性发出的类型都应该从基类型继承,例如:#include#include#include#includestructCommandBase{virtualvoidcommandAction(){std::coutvalueB;virtualvoidcommandAction(){std::coutlabelName;std::vector>commands;virtualvoidcommandAction(){std::coutc,comm