Questions tagged [boost-spirit-lex]

60 questions
15
votes
1 answer

How to benchmark Boost Spirit Parser?

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…
10
votes
1 answer

I can't get the string value of a token

I try to implement a Lexer for a little programming language with Boost Spirit. I have to get the value of a token and I get a bad_get exception : terminate called after throwing an instance of 'boost::bad_get' what(): boost::bad_get: failed…
Baptiste Wicht
  • 7,472
  • 7
  • 45
  • 110
6
votes
1 answer

Why does this boost::spirit::qi rule not match the input?

I tried to continue to work on my previous example and expand the rules. My problem is, that rules that use ID_IDENTIFIER do not work - although I know that the lexer is working (using unit tests). Here's the example: #include…
Tobias Langner
  • 10,634
  • 6
  • 46
  • 76
6
votes
1 answer

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

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: //…
May Oakes
  • 4,359
  • 5
  • 44
  • 51
5
votes
1 answer

Troubles with boost::spirit::lex & whitespace

I try learning to use boost::spirit. To do that, I wanted to create some simple lexer, combine them and then start parsing using spirit. I tried modifying the example, but it doesn't run as expected (the result r isn't true). Here's the…
Tobias Langner
  • 10,634
  • 6
  • 46
  • 76
5
votes
1 answer

How do I convert a boost::spirit::lex token's value from iterator_range to a string?

When I try to convert the value of a token from iterator_range, the lexer fails when attempting to read the next token. Here's the Tokens struct which holds the token definitions: (I don't think this is relevant but I'm including just in…
May Oakes
  • 4,359
  • 5
  • 44
  • 51
4
votes
2 answers

How to go about adding a symbol table interface to boost::spirit::lex based lexer?

To implement support for typedef you'd need to lookup the symbol table when ever the lexer identifies a identifier and return a different token. This is easily done in flex lexer. I am trying to use boost Spirit to build the parser and looked about…
Uday
  • 150
  • 1
  • 5
4
votes
1 answer

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

Let's consider following code: #include #include #include #include #include #include #include #include…
Adam Badura
  • 5,069
  • 1
  • 35
  • 70
4
votes
1 answer

boost spirit: how to match any lexer token in qi?

I would like to match a C++ function declaration with default argument values, but ignoring these values. For example: int myFunction(int a, int b = 5 + 4); Here is (a part of) the lexer: struct Lexer : boost::spirit::lex::lexer { …
4
votes
3 answers

Boost Spirit Signals Successful Parsing Despite Token Being Incomplete

I have a very simple path construct that I am trying to parse with boost spirit.lex. We have the following grammar: token := [a-z]+ path := (token : path) | (token) So we're just talking about colon separated lower-case ASCII strings here. I have…
Craig Wright
  • 1,575
  • 1
  • 11
  • 19
4
votes
1 answer

How do I use a qi::symbols parser to match tokens from a spirit lexer using no_case?

I have a lexer based on spirit::lexertl that produces tokens defined with lex::token_def. I'd like to use a qi::symbols<> table to match tokens in that table, using the associated data from the symbol table as the attribute in the rule.…
Tim Ruddick
  • 1,375
  • 16
  • 24
3
votes
2 answers

How to use a pointer as token attribute in Boost::Spirit::Lex?

I write a minimum example to demonstrate this problem. It parses nested list of numbers like (1 2 3 (4 5) (6 (7 (8)))). I use spirit::lex to parse number and spirit::qi to parse list, so I code like this: using TokenTypes =…
yhgu2000
  • 193
  • 6
3
votes
2 answers

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

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…
user8434768
3
votes
1 answer

Whitespace skipper when using Boost.Spirit Qi and Lex

Let's consider following code: #include #include #include #include #include #include #include namespace lex =…
Adam Badura
  • 5,069
  • 1
  • 35
  • 70
3
votes
1 answer

Can`t compile boost spirit example4.cpp

I am continuing to learn the Boost Spirit library and I have some issue with example that I couldn`t compile. The source of example you can find here: source place. Also you can look at this code and compile result on Coliru. #include…
AeroSun
  • 2,401
  • 2
  • 23
  • 46
1
2 3 4