Questions tagged [boost-spirit-lex]

60 questions
2
votes
1 answer

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

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

Boost::spirit get value from non-terminal

I have this, in my boost::spirit grammar; paren = (qi::token(LEFT_PAREN) >> character >> qi::token(RIGHT_PAREN)) [ build_paren ] ; character = qi::token(CHARACTER) [ build_character] ; Where these are defined…
Skeen
  • 4,614
  • 5
  • 41
  • 67
2
votes
1 answer

unhandled exception using Boost Spirit to parse grammar

I am trying to use Boost Spirit to parse the following grammar: sentence: noun verb sentence conjunction sentence conjunction: "and" noun: "birds" "cats" verb: "fly" "meow" parsing succeeds when the grammar only includes noun >> verb rule. when…
user2149346
  • 295
  • 1
  • 8
2
votes
1 answer

cannot compile boost-spirit example for changing token value using Phoenix actor

When i try to compile the code below (using the example from boost\spirit\home\lex\argument.hpp: value_setter) I get the following compiler error: c:\program files (x86)\boost\boost_1_50\boost\range\iterator.hpp(63) : error C2039: 'type' : is not a…
coproc
  • 6,027
  • 2
  • 20
  • 31
2
votes
1 answer

conversion to token_def's value type

When I define in lexical analyzer typedef boost::mpl::vector token_value_types; lex::token_def lit_uint("[0-9]+", token_ids::lit_uint); and then use it in some grammar as primary_expr = …
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
2
votes
1 answer

how to get spirit's qi::as_string to work with repeat?

For some odd reason, I can't get qi::as_string[] to work with repeat()[]. Parsing std::string str = { "{ +100S+++ ;\n }" };, I get the following OUTPUT PLUS OR MINUS+ THREE PLUS OR MINUS PARSED FINE ------------------------- Parsing…
kfmfe04
  • 14,936
  • 14
  • 74
  • 140
2
votes
1 answer

Trouble with boost::spirit::lex - punctuation characters

I want to create a lex::token_def<> that contains character sequences like '[' or ']' or '&>' I tried escaping the necessary characters: namespace lex = boost::spirit::lex; enum LexerIDs { ID_IDENTIFIER, ID_WHITESPACE, ID_INTEGER, ID_FLOAT,…
Tobias Langner
  • 10,634
  • 6
  • 46
  • 76
2
votes
1 answer

Retrieving the ID of a token_def<>

Is it possible to retrieve the ID of a token defined in the lexer like this: token_def<> tok; from inside the semantic action of a Spirit parser. What I'm trying to do is to use the token ID of every operator (like +, -, *, etc.) and retrieve a…
Haitham Gad
  • 1,529
  • 2
  • 13
  • 23
2
votes
1 answer

Eliminating syntactic sugar using Spirit.Qi

I'm trying to parse a lisp-like language which has some syntactic sugar for common functions. For example, the plus function can be written as (+ 1 2) or as 1 + 2. I'm thinking that eliminating syntactic sugar before trying to interpret the language…
Haitham Gad
  • 1,529
  • 2
  • 13
  • 23
1
vote
1 answer

I can't get Semantic actions in Boost Spirit's lexer functionality to compile

So, I'm using boost 1.47.0 and I've been trying to put together a lexer. My goal is to add to some of the tokens of my lexer a semantic action containing spirit::lex::_pass = spirit::lex::pass_flags::pass_ignore. However, I haven't been able to get…
Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
1
vote
1 answer

Why boost spirit lex hung instead parse error?

I long time didnt work with boost::spirit and back again. And stuck at simple case (omg, sometimes I want to kill this library...why why why so simple task is so complex with boost). #include #include #include…
AeroSun
  • 2,401
  • 2
  • 23
  • 46
1
vote
1 answer

Spirit Fails to Parse After only Appearing to get First symbol From the Lexer

Recently, I asked a question here: Boost Spirit Segfault In Parser In this post it was pointed out the grammar I was working with was absolutely left recursive and that spirit is a PEG parser generator, meaning left recursion is impossible. I…
joshu
  • 463
  • 8
  • 18
1
vote
1 answer

Can`t compile boost spirit word_count_lexer example

I am continuing to learn the Boost Spirit library and have comile 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
vote
1 answer

Why does qi::skip fail with tokens from the lexer?

I'm using boost::spirit lex and qi to parse some source code. I already skip white spaces from the input string using the lexer. What I would like to do is to switch skipping the comments depending on the context in the parser. Here is a basic demo.…
1
vote
1 answer

How to use a slash in Spirit Lex patterns?

Code below compiles fine with clang++ -std=c++11 test.cpp -o test But when running an exception is thrown terminate called after throwing an instance of 'boost::lexer::runtime_error' what(): Lookahead ('/') is not supported yet. The…
user1587451
  • 978
  • 3
  • 15
  • 30