On 02/04/2013 03:13, Walter Bright wrote:

1) Grammar defined in terms of things that aren't tokens. Take, for
example,
PropertyDeclaration. It's defined as an "@" token followed by... what?
"safe"?
It's not a real token. It's an identifier. You can't parse this based on
checking the token type. You have to check the type and the value.

True, do you have a suggestion?

I don't think that kind of grammar issue is too annoying, since it's easy to understand what the intended behavior is (in this case at least). But to fix it, well, we can have just that: have the grammar say it should parse an identifier after the @, and then issue a semantic error of sorts if the value is not one of the expected special values (safe, etc.). Parsing an identifier here is in any case the best error recovery strategy anyways.

A bit more annoying is the case with the extern declaration, with the C++ parameter:
  extern(C++)
here you have to look at a special identifier (the C, D, PASCAL part) and see if there is a ++ token ahead, it's a bit more of special-casing in the parser. Here I think it would have been better to change the the language itself and use "CPP" instead of "C++". A minor simplification.

--
Bruno Medeiros - Software Engineer

Reply via email to