正在加载图片...
Semantic Analyzer A semantic analyzer checks the source program for semantic errors and collects the type information for the code generation. Type-checking is an important part of semantic analyzer. 。 Normally semantic information cannot be represented by a context-free language used in syntax analyzers. Context-free grammars used in the syntax analysis are integrated with attributes (semantic rules) the result is a syntax-directed translation, -Attribute grammars ·EX: newval :oldval 12 The type of the identifier newval must match with type of the expression (oldval+12) CS308 Compiler Theory 10Semantic Analyzer • A semantic analyzer checks the source program for semantic errors and coll h i f i f h d i llects the type information for the code generation. • Type-checking is an important part of semantic analyzer. • Normally semantic information cannot be represented by a context-free language used in syntax analyzers. • Ctt on ex -f d i th t l i i t t d ith free grammars used in the syntax analysis are integrated with attributes (semantic rules) – the result is a syntax the result is a syntax-directed translation directed translation, – Attribute grammars • Ex: newval := oldval + 12 • The type of the identifier newval must match with type of the expression (oldval+12) 10 The type of the identifier newval must match with type of the expression (oldval 12) CS308 Compiler Theory
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有