TobyInkster.co.uk

Articles Tagged with “Parsers”

10/02/2007: Re: Parsing Question…

cjl wrote:

Short of writing a parser, which is clearly beyond me, what are some reasonable approaches to handling user input that will be executed?

Writing a parser is the best option in the long-run. If you were to attempt to interpret the user input some other way, like pure regular expressions, then you would fall into a lot of traps, and your interpreter would behave oddly in many cases.

A full parser is a much better option: it will behave far more reliably and would be a lot easier to extend, should you feel the need to add extra features to the language at a later date.

Although it’s a lot of work, there are some fairly well established methods on writing them. What you basically need to write is three fairly independent components: a tokeniser, a parser and an interpreter. None of these share any code in common, except for the definitions of a few constants and classes.

Firstly, a tokeniser, which reads the user input and splits it into a long list of tokens. Each token should have the…

Google Search

Blogroll

Here are some other sites. Some might be good; some might be rubbish. You decide.