Whitespace

From RAD Studio
Jump to: navigation, search

Go Up to Whitespace Overview Index

Whitespace is the collective name given to spaces (blanks), horizontal and vertical tabs, newline characters, and comments. Whitespace can serve to indicate where tokens start and end, but beyond this function, any surplus whitespace is discarded. For example, the two sequences

int i; float f;

and

int i;
   float f;

are lexically equivalent and parse identically to give the six tokens:

  • int
  • i
  • ;
  • float
  • f
  • ;

The ASCII characters representing whitespace can occur within literal strings, in which case they are protected from the normal parsing process (they remain as part of the string). For example,

char name[] = "Embarcadero Technologies";

parses to seven tokens, including the single literal-string token "Embarcadero Technologies"

Line splicing with \

A special case occurs if the final newline character encountered is preceded by a backslash (\). The backslash and new line are both discarded, allowing two physical lines of text to be treated as one unit.

"Embarcadero\
Technologies"

is parsed as "Embarcadero Technologies" (see String constants for more information).

See Also