Best practices for writing a programming language parser

前端 未结 7 1869
故里飘歌
故里飘歌 2020-12-14 16:49

Are there any best practices that I should follow while writing a parser?

7条回答
  •  时光取名叫无心
    2020-12-14 17:31

    Few pieces of advice:

    • Know your grammar - write it down in a suitable form
    • Choose the right tool. Do it from within C++ with Spirit2x, or choose external parser tools like antlr, yacc, or whatever suits you
    • Do you need a parser? Maybe regexp will suffice? Or maybe hack a perl script to do the trick? Writing complex parsers take time.

提交回复
热议问题