Writing a Parser

Dan murpsoft at hotmail.com
Sun Jan 6 00:35:03 PST 2008


Dan Wrote:

> 
> I've been messing with how to write a parser, and so far I've played with numerous patterns before eventually wanting to cry.
> 
> At the moment, I'm trying recursive descent parsing.

I've got it performing rather nicely now, for it's completeness.

parseOperand()
  returns an { ident, int, double, string, regexp, expression, arrayliteral, objectliteral *value* }
  incomplete for e notation numbers
  incomplete for expression, arrayliteral, objectliteral

parseBinaryOperator()
  returns one of the binary operator tokens

parseOptionalWS()
  consumes whitespace and doesn't return anything

I've got some more written, but they're not tested.  Once I have numbers done, I'll try writing the arrayLiteral, which will of course, parseOperand() "," parseOperand()

: )


More information about the Digitalmars-d-learn mailing list