I've been looking recently at Boost.Spirit (the version included in Boost 1.39), however I'm quite confused from the docs alone. What I'm looking for is for an example of a toy language implemented with Boost.Spirit -- something along the lines of a tiny Javascript or Lua or so, where you basically create an AST and process is. I'd be happy if it just supports function/variable definitions and the basic operators, I just want to see how you would create a normal AST using Boost.Spirit, and how to implement basic rules like identifiers, declarations, etc.
So far, I've tried the calculator example, but it's unclear for me how to implement a larger grammar with Spirit. The mini_c example which is bundled on the other hand looks quite complicated already, and it's not too well documented. Is there some easy to understand guide to Boost.Spirit out there, or a book maybe?
Boost Spirit is an object-oriented, recursive-descent parser and output generation library for C++. It allows you to write grammars and format descriptions using a format similar to Extended Backus Naur Form (EBNF) directly in C++.
Spirit is a header file only library.
An introductory article from CP
A JSON parser implemented using Boost.Spirit from CodeProject
Spirit Application Repository
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With