Günther Schoch 64 Posted Tuesday at 04:53 PM (edited) Hi while testing a Delphi syntax parser, we struggled over a few line in the Delphi "Winapi.ShellAPI" interface. In opposite to 99.99% of similar declarations, 3 lines have no semicolon at the end function SHLoadNonloadedIconOverlayIdentifiers; external shell32 name 'SHLoadNonloadedIconOverlayIdentifiers'; function SHQueryRecycleBin; external shell32 name 'SHQueryRecycleBinW' function SHQueryRecycleBinA; external shell32 name 'SHQueryRecycleBinA' function SHQueryRecycleBinW; external shell32 name 'SHQueryRecycleBinW' function SHQueryUserNotificationState; external shell32 name 'SHQueryUserNotificationState' delayed; the 3 lines in the middle have no ending ';' (lines 1825 - 1827 for delphi 12.2). Is this really a valid Delphi syntax or just a glitch in the compiler? Edited Tuesday at 04:54 PM by Günther Schoch 2 Share this post Link to post
eivindbakkestuen 52 Posted Thursday at 12:06 AM Good question 🙂 There exists no official language definition, the closest you get if you ask is "whatever the compiler accepts". However, examples in "function" declaration documentation all end with ";" so the above missing semicolons would be a compiler anomaly. Report it, and Emb can at least fix the missing characters. 🙂 Share this post Link to post
Remy Lebeau 1533 Posted Thursday at 12:51 AM 33 minutes ago, eivindbakkestuen said: There exists no official language definition True, though there is the Declarations and Statements (Delphi) documentation, which does state all declarations are terminated by a semicolon. Share this post Link to post
Tommi Prami 138 Posted Thursday at 07:55 AM (edited) On 3/18/2025 at 6:53 PM, Günther Schoch said: Hi while testing a Delphi syntax parser, we struggled over a few line in the Delphi "Winapi.ShellAPI" interface. In opposite to 99.99% of similar declarations, 3 lines have no semicolon at the end function SHLoadNonloadedIconOverlayIdentifiers; external shell32 name 'SHLoadNonloadedIconOverlayIdentifiers'; function SHQueryRecycleBin; external shell32 name 'SHQueryRecycleBinW' function SHQueryRecycleBinA; external shell32 name 'SHQueryRecycleBinA' function SHQueryRecycleBinW; external shell32 name 'SHQueryRecycleBinW' function SHQueryUserNotificationState; external shell32 name 'SHQueryUserNotificationState' delayed; the 3 lines in the middle have no ending ';' (lines 1825 - 1827 for delphi 12.2). Is this really a valid Delphi syntax or just a glitch in the compiler? Maybe you could make bug report to emba, maybe they fixit or not. -Tee- Edited Thursday at 08:41 AM by Tommi Prami Share this post Link to post
Lars Fosdal 1829 Posted Thursday at 08:33 AM I see the same in the D12.3 source, but no errors show in the IDE. I copied the source to another unit and compiled it and it doesn't care about semi-colons for external function declarations - not even for those with the delayed keyword. Bug or feature? I don't know, but it certainly is not consistent with the rest of the language. 2 Share this post Link to post
Attila Kovacs 646 Posted Thursday at 08:46 AM (On a side note, you also don't need a semicolon if the next word is "end". If it's known, just ignore me.) 1 Share this post Link to post
PeaShooter_OMO 28 Posted Thursday at 08:54 AM (edited) 1 minute ago, Attila Kovacs said: On a side note, you also don't need a semicolon if the next word is "end" Strange how that triggers a an OCD response in me when I see it. Edited Thursday at 08:54 AM by PeaShooter_OMO 1 Share this post Link to post
DenkDirNix 0 Posted Thursday at 08:59 AM (edited) My Delphi-Parser wouldn't like to see such lines. Same for many other Parsers I suppose. But now I understand why Emba doesn't show (or have?) a Grammar for Object-Pascal Edited Thursday at 09:00 AM by DenkDirNix Share this post Link to post
Uwe Raabe 2126 Posted Thursday at 09:01 AM 6 minutes ago, Attila Kovacs said: you also don't need a semicolon if the next word is "end". In Pascal the semicolon is a statement separator and not part of the statement. Remember the if-then-else... Share this post Link to post
Jonah Jeleniewski 20 Posted Thursday at 09:11 AM The semicolon situation in routine directives has always been a weird part of the grammar. SonarDelphi parses the directives (overly) permissively to accommodate these sometimes-required-sometimes-not semicolons. If it's a "bug" then it's a longstanding one (I've tested it as far back as XE3, but it probably goes further). I put "bug" in quotations because this is a language without an official formalized grammar or specification. In my opinion, that means the official grammar is "whatever slop the compiler will accept and turn into machine code." Any narrowing of what the compiler will accept is a breaking grammar change that will break compilation for tons of real-world codebases. For any language/product concerned with backwards compatibility it's just The Wrong Thing To Do™. For more information, see: SonarDelphi grammar Joe White's Blog: Parsing directives Share this post Link to post
Attila Kovacs 646 Posted Thursday at 09:19 AM 9 minutes ago, Uwe Raabe said: In Pascal the semicolon is a statement separator and not part of the statement. Remember the if-then-else... so it should yield an error if there is a semicolon for nothing Would you mind filing an error report? 😉 Share this post Link to post
Uwe Raabe 2126 Posted Thursday at 09:48 AM 17 minutes ago, Attila Kovacs said: so it should yield an error if there is a semicolon for nothing Wrong! According to N.Wirth (Pascal User Manual and Report page 149) there is an Empty Statement: Quote The empty statement consists of no symbols and denotes no action. Share this post Link to post
Attila Kovacs 646 Posted Thursday at 09:56 AM Just now, Uwe Raabe said: Wrong! According to N.Wirth (Pascal User Manual and Report page 149) there is an Empty Statement: Ok, this explains why ;;;;'s are just fine. Share this post Link to post
Günther Schoch 64 Posted Thursday at 11:03 AM @All Thank you all for the interesting feedback. In the meantime I tried to get a "first opinion by embt" as well. Depending on that answer, I will raise then the necessary report(s) and link the number(s). 1 Share this post Link to post
Brian Evans 112 Posted Thursday at 11:56 AM In the full IDE more than just the compiler parses the code and some of the other parsers have been slow, flaky and unreliable for a long time. I don't think allowing and including code like this is helping any. Share this post Link to post
Remy Lebeau 1533 Posted Thursday at 02:43 PM 5 hours ago, Attila Kovacs said: (On a side note, you also don't need a semicolon if the next word is "end". If it's known, just ignore me.) That is not a bug, but a feature of the Pascal language. More formally, inside a block ('begin..end' or 'repeat..until'), a semicolon is a statement separator, not a statement terminator, unlike with other languages. The last statement in a block is never terminated by a semicolon. If you write a semicolon, then the last statement will be an "empty" statement. Another quirk of Pascal requires a semicolon to be omitted when an 'if..else' is inside of a 'case of..else' to avoid ambiguity over which statement the 'else' belongs to: https://stackoverflow.com/questions/7574603/why-do-single-statement-blocks-require-not-using-semi-colons Share this post Link to post
eivindbakkestuen 52 Posted Thursday at 09:36 PM Best guess, with a bug report, Emb will fix the pascal unit, but not change the compiler. But it needs to be logged first, no need to ask anybody 🙂 1 Share this post Link to post
Günther Schoch 64 Posted Friday at 03:08 PM OK - added the bug report RSS-3157 Share this post Link to post
Uwe Raabe 2126 Posted Friday at 03:52 PM I found the first entry of this function in Delphi 2010 and it misses the semicolon already. Share this post Link to post