Lexical analysis principles and lexical analysis principles
C/C ++. For example,/, =, and * have only one symbol, which is called a single character. For a symbol with multiple characters, for example, /*, and = contain two single characters, so it is called a multi-character symbol.
Therefore, each character entered by the compiler, for example,/, is used to determine whether the input is complete. If there is still * after the input, the compiler will combine multiple characters, re-determine whether the input is complete; otherwise, it is processed as one character.
The principle for the compiler to input characters is: to input as many characters as possible. When the compiler inputs a character, it enters the character from left to right one by one. If the character can constitute a symbol, other symbols will be entered, then judge whether it can constitute a multi-character string. If it can be entered, repeat the above process. This method was once just a big mouth principle.
1. Code understanding:
a --- b
It can be understood
a -- - b
But it is definitely not:
a- --b
When y = x/* p, an error occurs,
When a character is entered,/* will be entered. The big mouth principle works well. The compiler will think it is the annotation symbol and report an error if it has all the characters,
Solution:
Y = x/* p or y = x/(* p)
Technorati labels: C/C ++, Big Mouth principle, lexical analysis, single character, multiple characters