Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accidental space inserted - Why does this compile?

I accidentally hit the spacebar and wrote this:

lTTEvent .CustUpdateStatus := usUnchanged;

and was surprised to see that the compiler accepted the space in front of the dot (actually, any number of spaces).

Is the dot such a special character that the parser can interpret it correctly? How would that work in Pascal?

like image 622
Jan Doggen Avatar asked Apr 17 '13 12:04

Jan Doggen


People also ask

Why does LaTeX take so long to compile?

If you have several high-resolution PNG or JPEG images in your document, LaTeX has to resize them every time we compile the PDF, and this can take a long time. Here are some ways to get around this: Use PDF files instead of PNG files for diagrams and plots.

Why is Overleaf not compiling?

If your document compiles locally, but not on Overleaf, the most common causes are compilation timeouts, or the use of uncommon templates or packages that do not come standard with TeXLive.

How do I cancel compile Overleaf?

We are really pleased to say that we have now added a 'stop compile' button that will cancel a compile during compilation. You will no longer have to wait for a compile to timeout if the LaTeX is caught in a loop, instead look for the square stop button during compile.


1 Answers

The parser first translates text to tokens. So the text:

lTTEvent .CustUpdateStatus := usUnchanged;

Is translated to the tokens:

  • identifier
  • period
  • identifier
  • becomes
  • identifier
  • semicolon

The space is a whitespace and it can have three functions:

  • separator between tokens (for example between an identifier and a keyword).
  • a literal space (in that case it is included in a string.
  • cosmetic.

The first and last function spaces are lost in the translation to tokens.

An identifier and a period don't have any characters in common so there is no way those can be confused so a space is not required but it still can be used.

short answer

'lTTEvent' and '.' are tokens. Tokens can (sometimes) be separated by whitespace.

like image 77
Toon Krijthe Avatar answered Oct 12 '22 09:10

Toon Krijthe