2
我試圖使用升壓精神X3解析字符串成一個結構:解析字符串後面的字符串與精神X3名單列表
struct identifier {
std::vector<std::string> namespaces;
std::vector<std::string> classes;
std::string identifier;
};
現在我有一個解析器規則匹配的字符串像這個:
foo::bar::baz.bla.blub
foo.bar
boo::bar
foo
我的解析器規則看起來像這樣。
auto const nested_identifier_def =
x3::lexeme[
-(id_string % "::")
>> -(id_string % ".")
>> id_string
];
其中id_string
解析的alphanum
組合。 我知道這個規則不能解析我想要的,因爲在解析foo.bar
時,例如規則-(id_string % ".")
的這部分消耗了整個字符串。 我如何更改規則在結構中正確解析?