Questions tagged [boost-spirit-x3]

LL parser framework represents parsers directly as EBNF grammars in inlined C++14

281 questions
3
votes
1 answer

Spirit X3 no matching function for call to 'move_to'

Why this does not compile? (commented r3 will compile, but I want semicolon in the rule) #include #include #include #include struct v { std::string…
sms
  • 1,014
  • 10
  • 20
3
votes
1 answer

Avoid throwing expectation_failure when expectation parser fails

How to avoid throwing an exception, when expectation parser fails? I have a rule "function" > (!x3::lexeme[keyword >> !(x3::alnum | '_')] >> symbol) > ('(' > -lvalue_list > ')') > statements > "end" to parse code like: function a() return one…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
2
votes
4 answers

How to propagate binary operators in boost spirit x3?

I had recently with the help of the amazing sehe managed to advance my boost spirit x3 parser for hlsl (high level shading language) that is a c-like language for writing shader kernels for GPU's. Here is the rough grammar I am…
2
votes
1 answer

Trying to parse nested expressions with boost spirit x3

My ultimate goal is to write a hlsl shading language parser. My first experience with parsing has been by following bob nystrom's "crafting interpreters". The issue I am currently facing is that I am trying to parse a 'chained member access' …
2
votes
1 answer

Cleanest way to handle both quoted and unquoted strings in Spirit.X3

Buon giorno, I have to parse something such as: foo: 123 "bar": 456 The quotes should be removed if they are here. I tried: ((+x3::alnum) | ('"' >> (+x3::alnum) >> '"')) But the parser actions for this are of type variant ; is…
Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75
2
votes
2 answers

Parse complex numbers with Boost::Spirit::X3

I would like to write a Boost::Spirit::X3 parser to parse complex number with the following possible input format: "(X+Yi)" "Yj" "X" My best attempt so far is the following (Open on Coliru): #include #include #include…
Tachikoma
  • 179
  • 2
  • 9
2
votes
1 answer

Misunderstanding repeat directive - it should fail, but doesn't

I would like to write a grammar (highly simplified) with: grr := integer [ . integer ] with integer ::= digit { [ underline ] digit } Since the parsed literals are needed again later (the real grammar is more complex, not everything can be…
Olx
  • 163
  • 8
2
votes
1 answer

Make boost::spirit::symbol parser non greedy

I'd like to make a keyword parser that matches i.e. int, but does not match int in integer with eger left over. I use x3::symbols to get automatically get the parsed keyword represented as an enum value. Minimal example: #include…
Rudolf Lovrenčić
  • 147
  • 1
  • 2
  • 9
2
votes
1 answer

How to use u8_to_u32_iterator in Boost Spirit X3?

I am using Boost Spirit X3 to create a programming language, but when I try to support Unicode, I get an error! Here is an example of a simplified version of that program. #define BOOST_SPIRIT_X3_UNICODE #include…
2
votes
0 answers

Why is x3::raw necessary here?

The following code produces a large compiler error along the lines of static assertion failed: Size of the passed attribute is less than expected.: constexpr x3::rule variable = "Variable"; const auto variable_def =…
Matt
  • 20,108
  • 1
  • 57
  • 70
2
votes
1 answer

Boost Spirit x3 -- Parameterizing Parsers with other Parsers

I don't have a whole lot of code to show for this one because I haven't managed to get anything to work, but the high level problem is that I am trying to create a series of parsers for a family of related languages. What I mean by this is that the…
2
votes
1 answer

What are contexts in boost spirit X3?

Short version What are contexts (boost::spirit::x3::context) used for, what do they represent, why are they needed and not hidden to the end user, and what requirements should they meet for smooth compiling ? Especially when having parsers in…
Heyji
  • 1,113
  • 8
  • 26
2
votes
1 answer

Boost spirit x3: compound attribute compile time error (enum class)

I was recently writing a simplest possible parser using boost spirit x3. It contains 2 rules: identifier and a single character operator. Naturally, I implemented the operator using a symbol table, which produces an operator type enum class.…
Yurii A
  • 369
  • 2
  • 10
2
votes
1 answer

Boost spirit x3 tokenizer with annotation does not work

I was recently trying to implement a simplest tokenizer using boost spirit x3. The challenge I'm struggling with right now is retrieving the position of each token in the input stream. There is a good tutorial about annotation on the official…
Yurii A
  • 369
  • 2
  • 10
2
votes
1 answer

BOOST_SPIRIT_DEFINE not understand

I'm trying to write an expression parser with boost spirit x3. I based my new code on old code that I written years ago (and worked well) with Spirit 2.x (qi). The core of my code is: //Make new rule(s) for expression auto term = factor >>…
Claudio La Rosa
  • 141
  • 1
  • 2
  • 7