问题
I need to write a simple parser to a sort of Domain Specific Language.
It needs to have basic arithmatics with proper operators evaluation order and a syntax to call functions of the underlying environment which can be overloaded.
What is the simplest way to write such a parser? Is there something I can adapt or use out of the box? I'm writing in C++.
回答1:
Take a look at Boost Spirit.
回答2:
See MetaII parser technology. This tutorial walks you through everything:
http://www.bayfronttechnologies.com/mc_tutorial.html
回答3:
ANTLR will help you a lot.
回答4:
I used Ragel parse some data. It worked pretty well for me.
来源:https://stackoverflow.com/questions/788814/writing-a-simple-parser