I'm writing my own scripting language and I need a software tool which generates C++ code for parsing my language. I need a lexical analyzer and a parser generator which generates C++ code. It would be nice for me to be able also to generate a Visual C++ 2010 project. Suggestions?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Correctly parse PDF paragraphs with Python
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- How do I get from a type to the TryParse method?
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
http://en.wikipedia.org/wiki/Comparison_of_parser_generators
for C/C++: http://epaperpress.com/lexandyacc/
Or look at: Boost.Spirit:
Dou you really need new language? maybe it would be better to use some well known like Lua, Python?
Try with Flex and Bison. They are good lexical analizers and parser generator usefull to define new languages.
http://en.wikipedia.org/wiki/Flex_lexical_analyser
It's an old question but still might be relevant: since I was unhappy with the existing options, I recently wrote a template c++ parser generator which doesn't need any external tools (you include a header and define the grammar directly in the c++ source). It uses readable PEG grammars so there is no need for a separate lexing step. You can check it out on Github.
You have two choices: whether you create your own parser by creating an AST (abstract syntax tree), then it will be a good exercise for you but it's very long and hard to implement. Or you can use an open source solution such the ANTLR parser generator which has a grammar for C/C++ as well as the preprocessor. I've never used it so I can't say how complete its parsing of C++ is going to be. Then If you are in hurry and you want to create a good parser, you'd better use the second solution