Joe White’s Blog

Life, .NET, and Cats


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,"'"


/blockquote>

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.

2 Responses to “Delphi grammar trivia of the day: double-quoted strings”

  1. Fatih Tolga Ata Says:

    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.

  2. Joe White Says:

    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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Joe White's Blog copyright © 2004-2011. Portions of the site layout use Yahoo! YUI Reset, Fonts, and Grids.
Proudly powered by WordPress. Entries (RSS) and Comments (RSS). Privacy policy