1

I have to parse an indentation based language (like python, yaml or coffee), and thinking about using spirit X3.

I know I can use Spirit Lex or some other lexer library for generating indent/dedent tokens.

Does X3 provide another way to accomplish this, without using an additional library?

Are there already already implemented X3 grammars for similar languages?

While looking for possible other solutions, I found this blogpost and some related threads on mailing lists, which states that

While it is possible to parse python using just straight Spirit.Qi, however, it looks messy to mixing the low level indentation handling in the parsing level.

Which is about Spirit Qi, but:

  • it doesn't provide a concrete answer how it can be done without lex.
  • I'm not too familiar with Qi or X3, but based on the docs, I don't see how I could implement this functionality without Lex.

I'm not necessarily looking for a complete solution, just for some pointers into the right direction.

Dutow
  • 5,638
  • 1
  • 30
  • 40
  • See https://www.boost.org/doc/libs/1_69_0/libs/spirit/doc/x3/html/spirit_x3/quick_reference/directive.html - `repeat` can take a run-time dependent value. I'm not sure how convenient it would be though. – Xeverous Jan 08 '19 at 16:58

0 Answers0