Forum > Editor

Possible syntax highlighting bug

<< < (3/4) > >>

PascalDragon:

--- Quote from: 440bx on July 19, 2024, 04:47:01 pm ---I use that little table in the snapshot somewhat often (it's part of the editor I use), that's why the "^(" immediately raised a red flag in my mind.  I knew there was no such thing as a "^(" control/"or otherwise" character.

Hopefully an FPC developer will see this thread/posts and emit an opinion.

--- End quote ---

Delphi also compiles code like this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Writeln(Ord(^A), ' ', Ord(^)), ' ', Ord(^());
The returned value is simply an addition/substraction by 64:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---                       if c<#64 then                         cstringpattern[len]:=chr(ord(c)+64)                       else                         cstringpattern[len]:=chr(ord(c)-64);

440bx:
@PascalDragon,

I don't know if you saw the bug report I created about these invalid control characters, my points are:

1. that Delphi accepts it does not make it right.
2. the ASCII standard defines the set of valid control characters and ^( , ^) are not in the set, thus they are invalid.

Lastly, presuming the character "f" is ^%, the character "o" is ^$ and "r" is ^1 then whoever wants to argue that those control sequences are valid has to explain why neither FPC nor Delphi accepts:
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---^%^$^! ^(:= 1 to 5 do begin end; { for i := 1 to 5 ... etc }
For some "odd" reason the compiler's scanner doesn't accept these "valid" control characters but has no problems accepting those defined by the standard. (t accepts them in a writeln statement.)

PS: I didn't, nor will I, take the time to figure out what invalid control characters represent the string "for" (not worth the time.)

Martin_fr:
The control chars are strings (or a char in quotes). Much the same as #65 is 'A' it is not just A.

So your example

--- Quote ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    ^%^$^! ^(:= 1 to 5 do begin end; { for i := 1 to 5 ... etc }
--- End quote ---
translates to

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---'for' 'i':= 1 to 5 do begin end;
That is in no way a comment on the remainder of the statement. I.e. should or shouldn't there be custom sequences.

PascalDragon:

--- Quote from: 440bx on July 22, 2024, 11:39:17 pm ---I don't know if you saw the bug report I created about these invalid control characters, my points are:

1. that Delphi accepts it does not make it right.
2. the ASCII standard defines the set of valid control characters and ^( , ^) are not in the set, thus they are invalid.
--- End quote ---

No, I didn't saw the bug report (till now), but as MvC said, it's not a bug that you can use such sequences. And as he also wrote, TP and Delphi support it, thus FPC must support it at least in modes TP and Delphi as well and thus there isn't really a good argument to forbid it in the other modes either. Not to mention that nowadays it's also necessary for backwards compatibility.

440bx:
As I said in the previous post, that Delphi does it doesn't make it right.


Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version