Getting started guide for Boost.Spirit? [closed]

谁说我不能喝 提交于 2021-02-05 12:59:08

问题


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?


回答1:


An introductory article from CP

A JSON parser implemented using Boost.Spirit from CodeProject

Spirit Application Repository




回答2:


The Spirit documentation includes examples and tutorials. An example for generating an AST for a mini XML-like language is included. A very useful overview presentation by Joel de Guzman and Hartmut Kaiser is also available.




回答3:


please keep in mind there is a newer boost spirit version with the completely new approach towards generating AST.




回答4:


The book The Boost C++ Libraries has a chapter about Spirit which I personally found pretty useful. It's available online, here's a direct link:

Chapter 11. Boost.Spirit




回答5:


Using Spirit 2.3: Qi and Karma

I think this pdf is quite good for beginners.



来源:https://stackoverflow.com/questions/1124232/getting-started-guide-for-boost-spirit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!