Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-01

character escaping with ^LETTER

9 messages · 6 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dmitry Boyarintsev

Hello,

today I saw this kind of character escaping:
var
  a :char;
begin
  a:=^M; // char(13)
  writeln(^X);  // char(24)
end;

The code of the character is derived as ord(letter)-ord('A')+1 Not sure which pascal its inherited from... but Delphi 7 does compile it too.

I vaguely remember it seeing before once .. and ... a lot of time ago.

Should it be added to this page:
http://www.freepascal.org/docs-html/ref/refse8.html#x20-190001.8 ? (need a bug report created?) or is it documented somewhere else?

CodeTools syntax highlighter won't recognize the syntax as characters either (delphi 7 highlighter doesn't recognize it as a character escaping as well)

thanks,
Dmitry

Dmitry Boyarintsev
to Dmitry Boyarintsev

hmm.. the character escaping is somewhat tricky.
The following code compiles:
writeln(^_^));

thanks,
Dmitry

On Mon, Jan 19, 2015 at 8:17 AM, Dmitry Boyarintsev <

Show quoted text 31 lines
wrote: Hello, today I saw this kind of character escaping: var a :char; begin a:=^M; // char(13) writeln(^X); // char(24) end; The code of the character is derived as ord(letter)-ord('A')+1 Not sure which pascal its inherited from... but Delphi 7 does compile it too. I vaguely remember it seeing before once .. and ... a lot of time ago. Should it be added to this page: http://www.freepascal.org/docs-html/ref/refse8.html#x20-190001.8 ? (need a bug report created?) or is it documented somewhere else? CodeTools syntax highlighter won't recognize the syntax as characters either (delphi 7 highlighter doesn't recognize it as a character escaping as well) thanks, Dmitry
Frederic Da Vitoria
to Dmitry Boyarintsev: today I saw this kind of character escaping: var a :char; begin a:=^M; // char(13)…

2015-01-19 14:17 GMT+01:00 Dmitry Boyarintsev :

Show quoted text 16 lines
Hello, today I saw this kind of character escaping: var a :char; begin a:=^M; // char(13) writeln(^X); // char(24) end; The code of the character is derived as ord(letter)-ord('A')+1 Not sure which pascal its inherited from... but Delphi 7 does compile it too. I vaguely remember it seeing before once .. and ... a lot of time ago.

IIRC good old Turbo Pascal had this too.

Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org
Howard Page-Clark
to Dmitry Boyarintsev: hmm.. the character escaping is somewhat tricky. The following code compiles:…
Dmitry Boyarintsev wrote
Not sure which pascal its inherited from... but Delphi 7 does compile it too.

It was certainly a feature of the first TurboPascal, and perhaps was in even earlier Pascal compilers, enabling simple insertion of control characters from the keyboard.
Later superseded by the "control string" syntax (#nnn) which gave access to all 8-bit ASCII values, it was retained by Borland for backwards compatibility reasons. A complication for parsers since "^" has other meanings of far more significance in most Pascal code.

---
This email has been checked for viruses by Avast antivirus software. http://www.avast.com

leledumbo
to Dmitry Boyarintsev: today I saw this kind of character escaping: var a :char; begin a:=^M; // char(13)…
Should it be added to this page:

http://www.freepascal.org/docs-html/ref/refse8.html#x20-190001.8 ? (need a bug report created?) or is it documented somewhere else?

http://www.freepascal.org/docs-html/ref/refsu7.html

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/character-escaping-with-LETTER-tp5720795p5720802.html Sent from the Free Pascal - General mailing list .
Mattias Gaertner
to Dmitry Boyarintsev: today I saw this kind of character escaping: var a :char; begin a:=^M; // char(13)…
Show quoted text 6 lines
[...] a:=^M; // char(13) [...] CodeTools syntax highlighter won't recognize the syntax as characters either (delphi 7 highlighter doesn't recognize it as a character escaping as well)

FYI: Codetools do not have a syntax highlighter. In Lazarus the highligher of synedit (TSynPasSyn) is used.

Codetools should parse it correctly.

Mattias

Dmitry Boyarintsev
to leledumbo: http://www.freepascal.org/docs-html/ref/refse8.html#x20-190001.8 ? (need a bug report…
leledumbo wrote

The beginning of the section. Shame on me.
"The compiler is rather sloppy about the characters it allows after the caret, but in general one should assume only letters"

, characters are interpreted as following:
 '^' :
 begin
   readchar;
   c:=upcase(c);
   if c<#64 then
     c:=chr(ord(c)+64)
   else
     c:=chr(ord(c)-64);
  ...

thanks,
Dmitry

Dmitry Boyarintsev
to Mattias Gaertner: On Mon, 19 Jan 2015 08:17:52 -0500 FYI: Codetools do not have a syntax highlighter. In…

On Mon, Jan 19, 2015 at 11:05 AM, Mattias Gaertner <

Show quoted text 5 lines
wrote: FYI: Codetools do not have a syntax highlighter. In Lazarus the highligher of synedit (TSynPasSyn) is used.

I was hoping to hear that. I had some concerns about it at the time I was looking at SynEdit's code and saw a lot of {$ifdef lazarus}. SynPas doesn't recognize the expression as a character, but I can't say that's a big issue :)

thanks,
Dmitry