boost-spirit-qi

Boost Spirit kwd parser in Visual Studio 2013

你。 提交于 2019-11-28 11:04:50
问题 I'm using Boost 1.57 with Visual Studio 2010. I would like to upgrade my project to Visual Studio 2013 but i'm having some problem with the boost Spirit parser. Seem to me that the kwd parser is broken somehow. The following code compiles correctly in Visual Studio 2010: #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/repository/include/qi_kwd.hpp> #include <boost/spirit

Whitespace skipper when using Boost.Spirit Qi and Lex

我的未来我决定 提交于 2019-11-28 09:08:04
问题 Let's consider following code: #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/qi.hpp> #include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> namespace lex = boost::spirit::lex; namespace qi = boost::spirit::qi; template<typename Lexer> class expression_lexer : public lex::lexer<Lexer> { public: typedef lex::token_def<> operator_token_type; typedef lex::token_def<> value_token_type; typedef lex::token_def<> variable_token

Cannot get Boost Spirit grammar to use known keys for std::map<>

梦想的初衷 提交于 2019-11-28 06:26:04
问题 I seem to be experiencing some mental block with Boost Spirit I just cannot get by. I have a fairly simple grammar I need to handle, where I would like to put the values into a struct, that contains a std::map<> as one of it's members. The key names for the pairs are known up front, so that only those are allowed. There could be one to many keys in the map, in any order with each key name validated via qi. The grammar looks something like this, as an example. test .|*|<hostname> add|modify

Parsing escaped strings with boost spirit

人走茶凉 提交于 2019-11-28 04:10:37
问题 I´m working with Spirit 2.4 and I'd want to parse a structure like this: Text{text_field}; The point is that in text_field is a escaped string with the symbols '{', '}' and '\'. I would like to create a parser for this using qi. I've been trying this: using boost::spirit::standard::char_; using boost::spirit::standard::string; using qi::lexeme; using qi::lit; qi::rule< IteratorT, std::string(), ascii::space_type > text; qi::rule< IteratorT, std::string(), ascii::space_type > content; qi::rule

Boost Spirit QI slow

半腔热情 提交于 2019-11-28 03:53:46
问题 I try to parse TPCH files with Boost Spirit QI. My implementation inspired by the employee example of Spirit QI ( http://www.boost.org/doc/libs/1_52_0/libs/spirit/example/qi/employee.cpp ). The data is in csv format and the tokens are delimited with a '|' character. It works but it is very slow (20 sec. for 1 GB). Here is my qi grammer for the lineitem file: struct lineitem { int l_orderkey; int l_partkey; int l_suppkey; int l_linenumber; std::string l_quantity; std::string l_extendedprice;

Spirit unable to assign attribute to single-element struct (or fusion sequence)

假装没事ソ 提交于 2019-11-28 01:57:27
My goal is to have my qi::grammar return an attribute. I'm having significant difficulty doing this with a spirit::lexer though. I'd expect that with the given grammar below, if I called it with spirit::qi::parse(begin, end, grammar, output); , that the struct ident output would have the contents of the parsed lexeme. The error seems to mostly flow out of this line: start %= lexer.identifier; System Notes Boost 1.47.0 Mac OS X 10.7.2 clang++ or g++ (errors shown below are from clang++) Compile Command g++ -g -c -O0 -Wall -DBOOST_SPIRIT_DEBUG -DBOOST_SPIRIT_LEXERTL_DEBUG -DBOOST_SPIRIT_USE

Parsing a command language using Boost Spirit

笑着哭i 提交于 2019-11-28 01:52:14
问题 I am building a parser for a command language that I've pieced together from various samples. I've read the Boost Spirit Qi and Lex docs, and I think I understand the basics, but from what I've read, I should avoid attributes and use utree. What docs I've found on utree basically suck. Given the code below, I have the following questions: How do I annotate the parser to create an AST using utree? How do I walk the utree after it is built, to discover what was parsed? e.g. for token-only

Using lexer token attributes in grammar rules with Lex and Qi from Boost.Spirit

 ̄綄美尐妖づ 提交于 2019-11-28 01:25:59
问题 Let's consider following code: #include <boost/phoenix.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/qi.hpp> #include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> namespace lex = boost::spirit::lex; namespace qi = boost::spirit::qi; namespace phoenix = boost::phoenix; struct operation { enum type { add, sub, mul, div }; }; template<typename Lexer> class expression_lexer : public lex::lexer<Lexer> { public: typedef

boost::spirit::qi keywords and identifiers

别等时光非礼了梦想. 提交于 2019-11-28 01:18:33
I've seen a few posts related to the nuances of keyword/identifier use in qi grammars, but I can't quite make sense of how the approach demonstrated in the boost examples is supposed to work... Keywords declaration: qi::symbols<char> keywords; Example keyword set: keywords.add ("foo") ("bar") ; Identifier rule declaration: qi::rule<std::string::const_iterator, std::string(), ascii::space_type> identifier; Here's how the identifier rule is defined in the qi calc and compiler examples: identifier = !keywords >> qi::raw[ qi::lexeme[ ( qi::alpha | '_' ) >> *( qi::alnum | '_' ) ] ]; Perhaps I'm

boost::spirit access position iterator from semantic actions

荒凉一梦 提交于 2019-11-27 23:05:10
Lets say I have code like this (line numbers for reference): 1: 2:function FuncName_1 { 3: var Var_1 = 3; 4: var Var_2 = 4; 5: ... I want to write a grammar that parses such text, puts all indentifiers (function and variable names) infos into a tree (utree?). Each node should preserve: line_num, column_num and symbol value. example: root: FuncName_1 (line:2,col:10) children[0]: Var_1 (line:3, col:8) children[1]: Var_1 (line:4, col:9) I want to put it into the tree because I plan to traverse through that tree and for each node I must know the 'context': (all parent nodes of current nodes). E.g,