-1

I'm writing a interpreter for one my custom scripting language. this is the actual project on GitHub : Link. if someone wants to help me would be appreciated :) however i need to implement a syntax checker for know if the syntax of code is correct from my parsed array of token. What is the best way?

P.S. here i don't want use lex/yacc or flex and bison.

Emanuele Pavanello
  • 785
  • 1
  • 9
  • 22
  • Since you have ruled out the other two most common parsers, I would say try boost::spirit or one of the other ones listed [here](https://en.wikipedia.org/wiki/Parsing#Parser_development_software) – David Brown Jul 05 '13 at 07:52
  • I want to implement the parser from me. Not using the other library. – Emanuele Pavanello Jul 05 '13 at 07:54
  • Well, "what is the best way to implement a parser" is too general and subjective a question for stackoverflow. Perhaps you can start trying to implement one and then ask a more specific question if you run into trouble. – David Brown Jul 05 '13 at 07:58
  • The best way (least effort and pain) is to use a parser generator, which you don't want to do. As a substitute, what you probably could do is hand-code a recursive descent parser. See this SO answer for details on how to do this: http://stackoverflow.com/a/2336769/120163 – Ira Baxter Jul 21 '13 at 22:11

1 Answers1

0

Either implement your own parser, or use yacc/bison.

The dragon book is a good place to start (http://en.wikipedia.org/wiki/Principles_of_Compiler_Design).

Also here is a sample C++ implementation of a top-down parser: http://en.wikipedia.org/wiki/LL_parser

Robert Kajic
  • 8,689
  • 4
  • 44
  • 43
  • sorry but i have just implemented the tokenizer. I need a logic for syntax checker, not for tokenizer with regex – Emanuele Pavanello Jul 05 '13 at 07:53
  • 1
    The tokens are not enough to do syntax checking. Either implement your own parser as well, or use yacc/bison. Have you heard about the dragon book (http://en.wikipedia.org/wiki/Principles_of_Compiler_Design)? Also here is a sample C++ implementation of a top-down parser: http://en.wikipedia.org/wiki/LL_parser – Robert Kajic Jul 05 '13 at 08:01
  • Yes thank you, I'm already reading that book for a while. – Emanuele Pavanello Jul 05 '13 at 08:04