Delphi grammar trivia of the day: double-quoted strings
Quoted strings, in Delphi, use single quotes. Almost always.
But did you know that the Delphi compiler supports double-quoted strings, too?
I didn’t either, until I wrote a Delphi lexer. I set it loose on all of the library source that ships with Delphi, and it complained about this " character that it didn’t understand. In SysUtils.pas, as it turns out, there’s a line that looks like this:
CMP AL,"'"
Yep. Inside an asm block, you can have a double-quoted character literal. And since I use the same lexer for all source files (i.e., I don’t have a separate lexer for asm blocks), I too have to support double-quoted strings.
But I only support double quotes around a single apostrophe: "'". After all, I don’t want to encourage this sort of thing.
August 27th, 2007 at 2:49 pm
Are you going to add class helpers and parametrized types? Secondly, I am wondering about, what are you using in your grammer list(http://www.excastle.com/dgrok/grammar.html). I mean that do you use pure html or a tool to generate this list.
August 28th, 2007 at 5:16 am
Thanks for mentioning class helpers. I didn’t have them in my list, but I’ve added a note. I’ll have to puzzle out the grammar later.
Parameterized types: I don’t have the Highlander beta, so I can’t really test those right now. I definitely will add them when I can.
As for the grammar document, that sounds like a good topic for another blog post.