联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2020-12-31 11:39

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.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp