[Soft test site analysis] Software designer-lexical, grammatical and semantic analysis

1. Title

The grammatical analysis performed in the compilation process is mainly the analysis of ____.
A Whether the identifier in the source program is legal
B Whether the meaning of the program statement is legal
C Whether the structure of the program statement is legal
D Whether the type of expression is legal

2. Theory

This question examines the differences between the stages of the compilation process: lexical analysis, grammatical analysis, and semantic analysis.

2.1 Lexical analysis

Lexical analysis is the analysis of words in the program , such as keywords and identifiers.

2.2 Syntax analysis

Grammatical analysis is based on lexical analysis to determine whether the program is structurally correct, just like the grammar in English. Each word pair does not mean that the entire sentence is correct. Grammar includes the arrangement of word order (structure).

2.3 Semantic analysis

Semantic analysis is even more advanced. Not only must the syntax be correct, but also whether the program has meaning errors. The common type of semantic analysis is type analysis to check whether the variable types in a line of code meet expectations.

3. Analysis

According to the above theory, A belongs to lexical analysis, B belongs to semantic analysis, and C belongs to grammatical analysis. So choose C.

Guess you like

Origin blog.csdn.net/woshisangsang/article/details/108569029