Lexical analysis principles and lexical analysis principles

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.