|Newbie parsing a simple bespoke language questions firstname.lastname@example.org (Chris Morley) (2007-12-10)|
|Re: Newbie parsing a simple bespoke language questions email@example.com (Chris Morley) (2007-12-12)|
|From:||"Chris Morley" <firstname.lastname@example.org>|
|Date:||Wed, 12 Dec 2007 19:25:22 -0000|
|Posted-Date:||12 Dec 2007 23:17:07 EST|
> [My advice is invariably to have the parser accept a larger language
> and do the type checking in your semantic code. That lets you
> produce useful error messages like "foo command requires two
> integers" rather than a generic syntax error. -John]
Humm... With %error-verbose you easily get "got integer expected
float" type messages but that is about the limit I guess without
jumping through too many hoops. Thanks. I have chosen the generic
parse + semantic check route now.
I need to parse fixed point numbers as well as integers. Is it better
to do things like this in the scanner & return a FP token + value or
make some rules and parse as 2 ints & '.'? (my scanner dumps all
whitespace between tokens at the moment so "123 . 456" is legal... but
I can fix that...) Is one way good/bad form?
Also is it bad form to use hints from the parser state to decipher
tokens (I have seen some webpages describing how to do this) -
e.g. for flag lookup "/f", change lookup from identifier string table
to flag string table to tokenise f after a '/'?
[Scanning floats can be surprisingly ugly, particularly if you allow
Fortran style 12.3E+4 exponents. I'd do it in the lexer. -John]
Return to the
Search the comp.compilers archives again.