Kevin
Kevin

Reputation: 697

^ meaning in "let's build a compiler" code

In Jack Crenshaw's "Lets' build a compiler" what does the ^I mean in this statement:

 const TAB = ^I;

He also uses ^G in one his functions.

Upvotes: 0

Views: 150

Answers (2)

Ringo Store
Ringo Store

Reputation: 636

From the Free Pascal Language Reference:

Also, the caret character ( ^ ) can be used in combination with a letter to specify a character with ASCII value less than 27. Thus ^G equals #7 - G is the seventh letter in the alphabet. The compiler is rather sloppy about the characters it allows after the caret, but in general one should assume only letters.

The result is a one-byte ASCII character constant. I is the 9th letter in the alphabet. And the ASCII value 9 is – no surprise – the TAB character.

Upvotes: 4

Callie J
Callie J

Reputation: 31306

It's Control-I. This translates to ASCII char-9, which is the character for Tab. Similarly Ctrl-G is ASCII char-7, which is the character for the BEL (literally bell), which usually generates a beep from a console.

Upvotes: 2

Related Questions