码迷,mamicode.com
首页 > 其他好文 > 详细

Homework 5: Semantic Analyzer

时间:2021-01-05 11:13:51      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:sem   sep   spec   change   roc   prepare   sed   and   mes   


Homework 5: Semantic Analyzer --
Experience
Purpose
Experience with coding a semantic analyzer for the Pym language. The computation is based on a
parse tree that is provided by a parser. The above picture is found from the internet, which
demonstrate some idea of the semantic analyzer, to embellish the tree with more particles (more data
like info of types and symbol tables). The language N has be introduced in the previous homeworks.
Preparation
In the folder code there are some provided code to help you. You can modify the code as you desire,
or fix errors if found some. For example, you can change the token types and content of a parse tree
node according to your work of previous homeworks. Read and understand the provided code.
The algorithm of a semantic analyzer has been discussed in class, and how to construct a semantic
analyzer for the C-minus language has been documented in details in the file cminus.pdf on FTP.
The same algorithm can be adjusted and similarly applied to build an analyzer for Pym.
The task
1. Provide a list of errors, and the corresponding error messages that will be detected by your
analyzer of Pym, like the error messages listed in cminus.pdf for the C-minus language. You
should prepare a separate file error_list.txt to describe the errors of Pym to be found by an
analyzer.
file:///C:/Users/liang/AppData/Local/Temp/mume20201119-17304-1mz8zoo.vk5lk.html 2/3
2. Provide the code of the analyzer. You can modify and use the provided code in the code folder.
Especially, definitions of some functions are missing. The comments of these missing functions
should provided sufficient information about them.
In the file symbol_table.c , which include:
st_insert_dcl()
st_insert_ref()
st_lookup()
In the file s_analyzer.c
pre_proc() : build the symbol tables and detect some error of names.
post_proc() : assign the type fields of the nodes and detect some error of types.
3. Test your analyer program with some Pym source program files. Especially, your program can do
the following
Print the symbol tables after they are built.
Detect some semantic errors of and print the corresponding error messages.

如有需要,请加QQ:99515681 或WX:codehelp

Homework 5: Semantic Analyzer

标签:sem   sep   spec   change   roc   prepare   sed   and   mes   

原文地址:https://www.cnblogs.com/blueskeyjava/p/14220601.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!