The parsing process of programming language

Source: Internet
Author: User

Example code:

1 if (A = = Ten) {2     printf ("hoge\n"); 3 Else {4     printf ("piyo\n"); 5 }

The syntax of a general programming language (which is not related to a compiled or interpreted language) will have the following process:

    1. Lexical analysis, the source code is divided into a number of tokens (token) processing;
      The sample part of the code is split into the following notation after the lexical parsing process is performed.

      The procedure for performing lexical analysis is called the lexical Analyzer (lexical analyzer), and Lex's job is to automatically generate a lexical parser based on the word rules.
    2. Syntax analysis, that is, the processing of the analysis tree from the notation, the analysis tree is also called the syntax tree, or is an abstract syntax tree;

      The program that performs the parsing is called the parser (parser), and YACC is the program that automatically generates the parser based on the syntax rules.
    3. Semantic analysis, parsing tree generated by parsing, does not contain semantic information such as data type, so in the semantic analysis phase, it checks whether the program contains errors with correct syntax but there are logic problems.

The parsing process of programming language

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.