Alex Rivera | Logout

Best practices for writing a programming language parser

Asked 2009-02-20T16:07:48.437
27

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

Edit
Report

1 Answer

2

First, don't try to apply the same techniques to parsing everything. There are numerous possible use cases, from something like IP addresses (a bit of ad hoc code) to C++ programs (which need an industrial-strength parser with feedback from the symbol table), and from user input (which needs to be processed very fast) to compilers (which normally can afford to spend a little time parsing). You might want to specify what you're doing if you want useful answers.

Second, have a grammar in mind to parse with. The more complicated it is, the more formal the specification needs to be. Try to err on the side of being too formal.

Third, well, that depends on what you're doing.

answered 2009-02-20T17:17:45.570

Your Answer