正在加载图片...
Syntax Analyzer Syntax Analyzer creates the syntactic structure of the given source program. This syntactic structure is mostly a parse tree. Syntax Analyzer is also known as parser. The syntax of a programming is described by a context-free grammar (CFG).We will use BNF(Backus-Naur Form)notation in the description of CFGs. 。 The syntax analyzer(parser)checks whether a given source program satisfies the rules implied by a context-free grammar or not. -If it satisfies,the parser creates the parse tree of that program. Otherwise the parser gives the error messages. A context-free grammar gives a precise syntactic specification of a programming language. -the design of the grammar is an initial phase of the design of a compiler. a grammar can be directly converted into a parser by some tools. CS308 Compiler Theory 2Syntax Analyzer • Syntax Analyzer creates the syntactic structure of the given source program. • Thi i i l This syntactic structure is mostly a parse tree. • Syntax Analyzer is also known as parser. • The syntax of a programming is described by a The syntax of a programming is described by a context context-free grammar (CFG) free grammar (CFG). We will We will use BNF (Backus-Naur Form) notation in the description of CFGs. • The syntax analyzer (parser) checks whether a given source program satisfies the rules i li d b implied by a context-free grammar or not. – If it satisfies, the parser creates the parse tree of that program. – Otherwise the parser gives the error messages. • A context-free grammar – gives a precise syntactic specification of a programming language. – the desigg p g p n of the grammar is an initial phase of the design of a compiler. – a grammar can be directly converted into a parser by some tools. CS308 Compiler Theory 2
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有