资源简介
语义分析程序的设计与实现
仅供参考。
语义分析 编译原理 北邮 大三
实验要求:编写语义分析程序,实现对算术表达式的类型检查和求值。要求所分析算术表达式由如下的文法产生。
实验要求:用自底向上的语法制导翻译技术实现对表达式的分析和翻译。
(1) 写出满足要求的语法制导定义或翻译方案。
(2) 编写分析程序,实现对表达式的类型进行检查和求值,并输出:
① 分析过程中所有产生式。
② 识别出的表达式的类型。
③ 识别出的表达式的值。
(3) 实验方法:可以选用以下两种方法之一。
① 自己编写分析程序。
② 利用YACC 自动生成工具。

代码片段和文件信息
/* A Bison parser made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison‘s Yacc-like parsers in C
Copyright (C) 1984 1989 1990 2000 2001 2002 2003 2004 2005 2006
Free Software Foundation Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation either version 3 of the License or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not see . */
/* As a special exception you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice so long as that work isn‘t itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively if you modify or redistribute
the parser skeleton itself you may (at your option) remove this
special exception which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman by
simplifying the original so-called “semantic“ parser. */
/* All symbols defined below should begin with yy or YY to avoid
infringing on user name space. This should be done even for local
variables as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted “INFRINGES ON
USER NAME SPACE“ below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION “2.4.1“
/* Skeleton name. */
#define YYSKELETON_NAME “yacc.c“
/* Pure parsers. */
#define YYPURE 0
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 0
/* Copy the first part of user declarations. */
/* Line 189 of yacc.c */
#line 1 “first.y“
#include
#include
#include
#include
#include
struct exp{
double value;
int type;
};
int length;
#define YYSTYPE struct exp
int yylex(void);
void yyerror(char * s);
int yywrap(void);
/* Line 189 of yacc.c */
#line 93 “first.tab.c“
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
/* Enabling verbose error messages. */
#ifdef YYER
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 167333 2017-12-04 21:11 语义分析\first.exe
文件 449 2017-12-04 21:11 语义分析\first.l
文件 46353 2017-12-04 21:11 语义分析\first.tab.c
文件 2101 2017-12-04 21:11 语义分析\first.tab.h
文件 2083 2017-12-04 21:11 语义分析\first.y
文件 37734 2017-12-04 21:11 语义分析\lex.yy.c
文件 437356 2017-12-04 21:11 语义分析\程序设计3 语义分析程序的设计与实现.pdf
目录 0 2017-12-04 21:11 语义分析
----------- --------- ---------- ----- ----
693409 8
- 上一篇:单片机MP3源码c51版
- 下一篇:上海大学编译原理试卷.
相关资源
- 编译原理实验工具及参考源码(lex&
- 类pascal语言编译器(编译原理实验)
- 编译原理课程设计:词法语法编译器
- 中科院 编译原理 习题及解答
- 编译原理四元式和逆波兰式
- 《编译原理》清华大学版中的pl0扩充
- PL/0功能扩充break功能
- 数据结构课件(北邮)
- 编译原理LR(0)语法分析
- 编译原理中间代码生成程序
- 编译原理:LR分析程序
- 编译原理实验:词法分析,语法分析
- 吉林大学编译原理课件
- 编译原理龙书答案
- 编译原理 第三章课后习题答案
- 易语言变量和数组的编译原理
- 编译原理语法分析器、词法分析器
- 山东大学编译原理PL/0语言 compiler实验
- 信号与系统郑君里北邮课件
- 卫星通信知识点总结不包含计算题
- 北邮 现代交换原理实验 sip电话 抓包
- 分布式温控系统,北邮软件工程作业
- FOR循环语句的翻译程序设计简单优先
- NFA的确定化NFA->DFA完整可运行代码
- 北邮高操期末试题答案及知识点总结
- 哈工大威海编译原理实验报告和源代
- 哈工大威海-编译原理实验报告和源码
- 北邮2015-2016专硕概率论与随机过程期
- 编译原理课设c编译器
- 赋值语句翻译四元式
评论
共有 条评论