boost-spirit-lex

cannot get boost::spirit parser&lexer working for token types other than std::string or int or double

倾然丶 夕夏残阳落幕 提交于 2019-12-30 11:03:10
问题 This does not compile (code below). There was another question here with the same error. But I don't understand the answer. I already tried inserting qi::eps in places -- but without success. I also tried already adding meta functions (boost::spirit::raits::is_container) for the types used -- but this also does not help. I also tried using the same variant containing all types I need to use everywhere. Same problem. Has anybody gotten this working for a lexer returning something else than

cannot get boost::spirit parser&lexer working for token types other than std::string or int or double

↘锁芯ラ 提交于 2019-12-30 11:02:36
问题 This does not compile (code below). There was another question here with the same error. But I don't understand the answer. I already tried inserting qi::eps in places -- but without success. I also tried already adding meta functions (boost::spirit::raits::is_container) for the types used -- but this also does not help. I also tried using the same variant containing all types I need to use everywhere. Same problem. Has anybody gotten this working for a lexer returning something else than

Spirit Lex: Which token definition generated this token?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 07:10:29
问题 Sorry if this is a newbie question, but I need to know which token definition produced a certain token. When I print the token ID, I just get an integer. I need to know which regex generated this token. Edit: Here's how I define my tokens: template <typename LexerT> class Tokens: public lex::lexer<LexerT> { public: Tokens(const std::string& input): lineNo_(1) { using boost::spirit::lex::_start; using boost::spirit::lex::_end; using boost::spirit::lex::_pass; using boost::phoenix::ref; using

Boost.Spirit SQL grammar/lexer failure

ぐ巨炮叔叔 提交于 2019-12-29 08:03:36
问题 I have two problems with the following SQL grammar: #define BOOST_SPIRIT_QI_DEBUG #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/lexical_cast.hpp> #include

Boost.Spirit SQL grammar/lexer failure

元气小坏坏 提交于 2019-12-29 08:03:11
问题 I have two problems with the following SQL grammar: #define BOOST_SPIRIT_QI_DEBUG #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/lex_lexertl.hpp> #include <boost/spirit/include/phoenix.hpp> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/algorithm/string.hpp> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include <boost/lexical_cast.hpp> #include

Parsing a tokenized free form grammar with Boost.Spirit

柔情痞子 提交于 2019-12-24 16:46:30
问题 I've got stuck trying to create a Boost.Spirit parser for the callgrind tool's output which is part of valgrind. Callgrind outputs a domain specific embedded programming language (DSEL) which lets you do all sorts of cool stuff like custom expressions for synthetic counters, but it's not easy to parse. I've placed some sample callgrind output at https://gist.github.com/ned14/5452719#file-sample-callgrind-output. I've placed my current best attempt at a Boost.Spirit lexer and parser at https:/

Is there a way to match the content of a spirit::lex string token as a literal in a spirit::qi grammar

可紊 提交于 2019-12-22 10:10:40
问题 I'm writing a DSL and using a Boost Spirit lexer to tokenize my input. In my grammar, I want a rule similar to this (where tok is the lexer): header_block = tok.name >> ':' >> tok.stringval > ';' >> tok.description >> ':' >> tok.stringval > ';' ; Rather than specifying reserved words for the language (e.g. "name", "description") and deal with synchronizing these between the lexer and grammar, I want to just tokenize everything that matches [a-zA-Z_]\w* as a single token type (e.g. tok.symbol

How to benchmark Boost Spirit Parser?

久未见 提交于 2019-12-17 16:06:30
问题 I'm working on a compiler and I would like to improve its performances. I found that about 50% of the time is spent parsing the source files. As the source file are quite small and I do quite a lot of transformations after that, it seems to me that it is perfectible. My parser is a Boost Spirit parser with a lexer (with lexer::pos_iterator) and I have a middle sized grammar. I'm parsing the source into an AST. My problem is that I have no idea what takes the most time during the parsing:

Flipping the order of subrules inside a rule in a boost::spirit grammar results in segfault

冷暖自知 提交于 2019-12-11 02:58:17
问题 Warning; while I tried to shorten the code down, to a minimum. I still had to include quite a bit, to ensure that the required information was present. This code, compiles files, and runs resulting in a syntax error; name = simple_name [ qi::_val = qi::_1 ] | qualified_name [ qi::_val = qi::_1 ] ; While this; name = qualified_name [ qi::_val = qi::_1 ] | simple_name [ qi::_val = qi::_1 ] ; Results in a SIGSEGV , Segmentation fault; boost::detail::function::function_obj_invoker4<boost::spirit:

How do I implement include directives using boost::spirit::lex?

旧时模样 提交于 2019-12-10 13:22:10
问题 I have a simple configuration file parser built from spirit::lex and spirit::qi. When the lexer reaches the pattern include "path" I want the text of the file to be included. As you may know, spirit::lexer::begin() starts the scanning process: // Read file contents into a std::string ... // _first and _last are const char* _first = _contents.c_str(); _last = &_first[_input.size()]; // _token is a lexer::iterator_type for the current token _token = _lexer.begin(_first, _last); My idea is to