正在加载图片...
Syntax Analyzer (CFG) The syntax of a language is specified by a context free grammar (CFG). The rules in a CFG are mostly recursive. A syntax analyzer checks whether a given program satisfies the rules implied by a CFG or not. If it satisfies,the syntax analyzer creates a parse tree for the given program. Ex:We use BNF(Backus Naur Form)to specify a CFG assgstmt -identifier :=expression expression -identifier expression -number expression -expression expression CS308 Compiler Theory 7Syntax Analyzer (CFG) • The syntax of a language is specified by a context free grammar ( ) CFG ). • The rules in a CFG are mostly recursive. • A syntax analyzer checks whether a given program satisfies the rules implied by a CFG or not. – If it satisfies the syntax analyzer creates a parse tree for the given program If it satisfies, the syntax analyzer creates a parse tree for the given program. • Ex: We use BNF (Backus Naur Form) to specify a CFG We use BNF (Backus Naur Form) to specify a CFG assgstmt -> identifier := expression ex pression -> identifie r expression -> number expression -> expression + expression CS308 Compiler Theory 7
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有