boost-spirit

How to match unicode characters with boost::spirit?

最后都变了- 提交于 2019-11-30 15:07:23
问题 How can I match utf8 unicode characters using boost::spirit ? For example, I want to recognize all characters in this string: $ echo "На берегу пустынных волн" | ./a.out Н а б е р е гу п у с т ы н н ы х в о л н When I try this simple boost::spirit program it will not match the unicode characters correctly: #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/support_istream_iterator.hpp> #include <boost/foreach.hpp> namespace qi = boost::spirit::qi; int main() { std::cin

Boost.Spirit: Lex + Qi error reporting

自古美人都是妖i 提交于 2019-11-30 14:53:51
问题 I am writing a parser for quite complicated config files that make use of indentation etc. I decided to use Lex to break input into tokens as it seems to make life easier. The problem is that I cannot find any examples of using Qi error reporting tools ( on_error ) with parsers that operate on stream of tokens instead of characters. Error handler to be used in on_error takes some to be able to indicate exactly where the error is in the input stream. All examples just construct std::string

Too many sections, assembler error, using boost::spirit

柔情痞子 提交于 2019-11-30 13:12:12
I'm in the progress of writing a compiler for a subset of Java, using boost::spirit , for lexing and parsing. During compilation of the lexer/parser phase, the compiler consumes 1.6GB of RAM ( g++ (GCC) 4.8.1 ), this is not an issue however, as there's plenty of memory on this machine. What is an issue however, is that when the compiler is done, and the assembler starts running ( GNU assembler (GNU Binutils) 2.23.52.20130604 ), it crashes with; as: build/src/ast_generate.o: too many sections (33098) /tmp/cc0ZyvKK.s: Assembler messages: /tmp/cc0ZyvKK.s: Fatal error: can't write build/src/ast

How to match unicode characters with boost::spirit?

谁都会走 提交于 2019-11-30 13:04:05
How can I match utf8 unicode characters using boost::spirit ? For example, I want to recognize all characters in this string: $ echo "На берегу пустынных волн" | ./a.out Н а б е р е гу п у с т ы н н ы х в о л н When I try this simple boost::spirit program it will not match the unicode characters correctly: #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/support_istream_iterator.hpp> #include <boost/foreach.hpp> namespace qi = boost::spirit::qi; int main() { std::cin.unsetf(std::ios::skipws); boost::spirit::istream_iterator begin(std::cin); boost::spirit::istream_iterator

Boost.Spirit: Lex + Qi error reporting

為{幸葍}努か 提交于 2019-11-30 12:03:37
I am writing a parser for quite complicated config files that make use of indentation etc. I decided to use Lex to break input into tokens as it seems to make life easier. The problem is that I cannot find any examples of using Qi error reporting tools ( on_error ) with parsers that operate on stream of tokens instead of characters. Error handler to be used in on_error takes some to be able to indicate exactly where the error is in the input stream. All examples just construct std::string from the pair of iterators and print them. But if Lex is used, that iterators are iterators to the

How to print the variables matched by the symbol table in Boost spirit parser?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 10:09:57
I am a beginner in using boost spirit Say that I have the following code that parse a simple arithmetic expression with variables: #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/variant/recursive_variant.hpp> #include <boost/variant/apply_visitor.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/spirit/include/phoenix_function.hpp> #include <boost/foreach.hpp> #include <iostream> #include <string> namespace client { namespace ast { struct nil {}; struct signed_; struct program; typedef boost::variant< nil , double , boost:

boost::spirit binding function providing parameteres as spirit:qi::_val

痞子三分冷 提交于 2019-11-30 09:41:38
问题 There is a need of providing the values from an object of type boost::variant for an std::pair object. How would you implement this idea using other resources? Any other way than this is done below? struct aggr_pair_visitor : public ::boost::static_visitor<void> { public: explicit aggr_pair_visitor( column_and_aggregate & pair_ ) : pair(pair_) { } void operator()(column_name_t const & column) { pair.first = column; } void operator()(unsigned const & faggr) { if ( faggr > static_cast<unsigned>

How to use boost::spirit to parse UTF-8?

醉酒当歌 提交于 2019-11-30 09:02:19
问题 #include <algorithm> #include <iostream> #include <string> #include <vector> #define BOOST_SPIRIT_UNICODE // We'll use unicode (UTF8) all throughout #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi_parse.hpp> #include <boost/spirit/include/support_standard_wide.hpp> void parse_simple_string() { namespace qi = boost::spirit::qi; namespace encoding = boost::spirit::unicode; //namespace stw = boost::spirit::standard_wide; typedef std::wstring::const_iterator iterator_type

Getting boost::spirit::qi to use stl containers

依然范特西╮ 提交于 2019-11-30 06:40:02
问题 I'm trying to parse something with boost.spirit's qi library, and I'm running into an issue. According to the spirit docs, a >> b should produce something with the type tuple<A, B> . But this is a boost::tuple (aka fusion vector), and not a std::tuple (which I want). Is there any easy way to make this conversion between boost::tuple => std::tuple ? The same documentation page says that *a should produce something with the type vector<A> . This seems to be producing a std::vector<A> (or some

How to parse entries followed by semicolon or newline (boost::spirit)?

倖福魔咒の 提交于 2019-11-29 21:35:26
问题 In Boost::Spirit, how can I parse entries that are followed by either a semicolon or by a newline with optional semicolon? Example input, where each entry is an int and a double: 12 1.4; 63 13.2 2423 56.4 ; 5 8.1 Here is example code that just parses entries followed by whitespace: #include <iostream> #include <boost/foreach.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/support_istream_iterator.hpp> #include <boost/fusion/include/std_pair.hpp> namespace qi = boost