ECE/CPSC 3520
Fall 2014
Software Design Exercise #1
Blackboard submission only
Assigned 9-08-2014
Due 9-24-2014 11:59PM
Contents
1 Preface 3
1.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 The Bigger Picture: SDEs 2 and 3 . . . . . . . . . . . . . . . . 3
2 Resources and Notation 4
2.1 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Prolog Argument Designations . . . . . . . . . . . . . . . . . . 4
3 The Lexical Constraints and Data Structures 5
3.1 Basic Lexical Constraints . . . . . . . . . . . . . . . . . . . . . 5
3.2 ’needs’ Predicate and Argument Syntax . . . . . . . . . . . . . 5
3.3 ’resources’ Predicate and Argument Syntax . . . . . . . . . . . 6
4 Using flex and bison to Validate The Syntactic Correctness
of an Input String 7
4.1 Entities to be Recognized . . . . . . . . . . . . . . . . . . . . 7
4.2 Naming and Building . . . . . . . . . . . . . . . . . . . . . . . 8
5 Sample Use 8
6 Notes 11
1
7 Format of the Electronic Submission 11
2
1 Preface
1.1 Objectives
The overall objectives of SDE1 are:
1. To introduce flex and bison as general purpose scanner/parser devel-
opment tools.
2. To use flex and bison to build a grammatical recognizer to check the
syntactic correctness of a set of data structures to be used in SDEs 2
and 3.
These data structures will be used with Prolog and ocaml to satisfy a
scheduling (CSP) problem (see the section below).
Alternately, we are designing, implementing and testing an application-
dependent syntactic recognizer, implemented as a scanner/parser.
3. To give you experience in grammatical inference. Given the specifica-
tions herein, you will design G and implement it using flex and bison.
Grammatical ambiguity is not desired.
All work is to be done on a linux platform. Your grade is based upon a
correctly working implementation. Significant in-class discussion will accom-
pany this SDE. Get started now.1
This is an individual (not group) effort.
1.2 The Bigger Picture: SDEs 2 and 3
As a part of my ’un-retirement’ from the ECE Graduate Coordinator posi-
tion, I am now faced with a significant problem every semester:
The ECE Department offers many undergraduate labs. These
labs must be staffed by graduate Teaching Assistants (TAs).
Thus, the framework for a real problem. The long-term purpose of this
project is to design, implement and test systems for the scheduling of ECE
Graduate student teaching assistants (TAs). All representation and manip-
ulation will be done using Prolog (SDE2) and ocaml (SDE3). System inputs
1At least install flex and bison.
3
include department TA needs and available TA capabilities. System output
will be an assignment of TAs to labs. Here, the problem is to check the
syntactic correctness of inputs.
2 Resources and Notation
2.1 Resources
As discussed in class, it would be foolish to attempt this SDE without care-
fully exploring:
1. The text, especially the many examples in Chapter 6;
2. The flex manual (http://flex.sourceforge.net/manual/); and
3. The bison manual (http://www.gnu.org/software/bison/manual/).
2.2 Notation
The data structures will be used as Prolog arguments in SDE2. For now,
we concentrate on the structure (syntax) of the arguments. This does two
things:
1. It gets you familiar with the data structures you’ll use in SDE 2; and
2. It provides an application for flex and bison.
2.3 Prolog Argument Designations
See the book, p. 77, Section 3.1.5. This was discussed in class. I show argu-
ment structure with a combination of the notation used for Prolog predicate
arguments (+,-,?) and the notation for the positive closure set (+). For
example,
+Course+
indicates a variable ’Course’, which is bound when used (the left +), and
may be repeated 1 or more times (the right +).
4
3 The Lexical Constraints and Data Struc-
tures
3.1 Basic Lexical Constraints
1. Days are atoms m,tu,w,th,f.
2. Times are unsigned integers and causal (Stop_Time > Start_Time).
You do not need to check for causality.
3. Sections are unsigned integers.
4. Course names are the letters ’ece’ followed by four digits.
5. Student names are variable-length and comprised of lowercase alpha-
betic characters, e.g., jason, freddy, michael.
6. White space (see the text and examples) is allowed.
You need to develop REs for each of these entities, as a precursor to
building a scanner. I strongly recommend you design, implement
and test a freestanding scanner first.
3.2 ’needs’ Predicate and Argument Syntax
needs([+Course_List+])
where
Course_List itself is a list of form:
[+Course_name,+Section,+Day,+Start,+End]
A sample ’needs’ argument is shown below:
[[ece2090,1,m,13,16],
[ece2090,2,tu,13,16],
[ece2090,3,w,13,16],
[ece2090,4,f,9,12],
[ece2060,1,tu,11,14],
[ece2060,2,tu,14,17],
[ece2060,3,w,9,12],
[ece2060,4,f,13,16],
[ece3520,1,tu,11,14],
5
[ece3520,2,tu,14,17],
[ece4420,1,w,13,16],
[ece4420,2,f,13,16]]
Thus, the predicate could be used in Prolog (SDE 2) as:
needs([
[ece2090,1,m,13,16],
[ece2090,2,tu,13,16],
[ece2090,3,w,13,16],
[ece2090,4,f,9,12],
[ece2060,1,tu,11,14],
[ece2060,2,tu,14,17],
[ece2060,3,w,9,12],
[ece2060,4,f,13,16],
[ece3520,1,tu,11,14],
[ece3520,2,tu,14,17],
[ece4420,1,w,13,16],
[ece4420,2,f,13,16]]).
Notice the (allowed) use of whitespace.
3.3 ’resources’ Predicate and Argument Syntax
The Prolog predicate ’resources’ is an arity-1 predicate whose single argument
is used to ’hold’ the list-structured database of resources.
resources([+Student_Resource+])
The resources argument is a list of the overall resources database and is
of (list-of-lists) form, where individual student resource entries are lists of
resources_entry structure:
[+Student_Name,+Course_Capabilities_List,+Unavailable_List]
The 2nd and 3rd elements of the above resources_entry are variable-
length lists. Course_Capabilities_List is just a list of courses the student
is qualified to TA for. Time periods a student is not available are represented
in Unavailable_List with structure
6
=[[+Day,+Start_Time,+Stop_Time]+]
An empty Unavailable_List = [] means a student is available 24/5.
As a note in the Prolog solution (later), you MUST revise a specific
student’s Unavailable when used in a generated schedule.
Sample resources and resource entries:
[[joe, [ece2090,ece2010,ece3520,ece4420],[[m,8,9]]],
[sam, [ece2010,ece4420],[[tu 9,11],[th,9,11]]],
[pete, [ece3520,ece4420],[]],
[randi, [ece2090],[]],
[gwen, [ece2090,ece2010],[]]]
4 Using flex and bison to Validate The Syn-
tactic Correctness of an Input String
Here you will treat scanning and parsing of an input file, using a prespecified
set of data structures, as if it were ’source code’ constrained by a grammar
whose corresponding language is shown in Section 3. I’ll discuss syntactic
correctness in class and show examples of correct and incorrect files.
This SDE MUST be done using both flex and bison (and c).
4.1 Entities to be Recognized
The examples presented (both valid and errors) should help in understanding
of the desired syntax.
The following syntactically correct valid expressions, later to be used as
Prolog arguments, are to be recognized:
• needs
• unavailable_list
• course_capabilities_list
• resources_entry
• resources (resources_list)
7
The astute reader will note that some of the above entities are parts of others
(e.g., resources_entry and resources_list). In this case, the recognizer
should recognize the larger entity, not the component.
As shown in the examples, after recognition of each, a printf statement is
used to signify recognition of a syntactically correct construct. The display
format shown in the examples is to be used.
4.2 Naming and Building
The evaluation of your work will be partially automated. Therefore, you
must adhere to a number of specifications. The flex input file is to be
named schedule.in; the bison file is to be named schedule.y; the c file
containing main is to be named schedule.c; and the linux executable is to
be named schedule. We will use flex and bison to build your executable
with the following script (buildit):
#! /bin/bash
## to build scanner/parser */
bison -d -v $1.y
flex $1.in
gcc $1.c -lfl -Wall -o $1
For reference, here is the building of my solution:
$./buildit schedule
$
Anybody see any errors or warnings?
5 Sample Use
Here are a few cases. I’ll discuss these in class. Your effort should follow the
output format shown.
$./buildit scheduler
$ cat needs
[[ece2090,4,f,9,12],
[ece2095,4,w,9,12],
[ece3090,1,tu,1,3]
8
]
$./schedule <needs
found valid ’needs’ list’
$cat bad_needs
[[ece2090,4,f,9,12],
[ece2095,w,9,12],
[ece3090,1,tu,1,3]
]
$./schedule <bad_needs
syntax error
$cat bad_needs2
[[ece2090,4,f,9,12],
[cpsc2095,4,w,9,12],
[ece3090,1,tu,1,3]
]
$./schedule <bad_needs2
syntax error
$cat unavail_list0
[]
$./schedule <unavail_list0
found valid ’unavailable_list’
$cat unavail_list1
[[tu,7,9],[w,13,16]]
$./schedule <unavail_list1
found valid ’unavailable_list’
$cat bad_unavail_list1
[[tu,7,9][w,13,16]]
$./schedule <bad_unavail_list1
syntax error
$cat bad_unavail_list2
[[tu,7,9],[w,13-16]]
$./schedule <bad_unavail_list2
syntax error
$cat course_capabilities_list1
[ece2090,ece2010,ece3520,ece4420]
$./schedule <course_capabilities_list1
9
found valid ’course_capabilities’ list
$cat bad_course_capabilities_list1
[[ece2090,ece2010,ece3520,ece4420]]
$./schedule <bad_course_capabilities_list1
syntax error
$cat resources_entry1
[sam, [ece2010,ece4420],[]]
$./schedule < resources_entry1
found valid ’resources_entry’ list
$cat bad_resources_entry1
[ece3400, [ece2010,ece4420],[]]
$./schedule < bad_resources_entry1
syntax error
$cat bad_resources_entry2
[jenny, [ece2010,ece4420],[12,13]]
$./schedule < bad_resources_entry2
syntax error
$cat resources2
[
[joe, [ece2090,ece2010,ece3520,ece4420],[[m,8,9]]],
[sam, [ece2010,ece4420],[[tu,9,11],[th,9,11]]],
[pete, [ece3520,ece4420],[]],
[randi, [ece2090],[]],
[gwen, [ece2090,ece2010],[]]
]
$./schedule <resources2
found valid ’resources list’
$cat resources2b
[[joe, [ece2090,ece2010,ece3520,ece4420],[[m,8,9]]],
[sam, [ece2010,ece4420],[[tu,9,11],[th,9,11]]],
[pete, [ece3520,ece4420],[]],
[randi, [ece2090],[]],
[gwen, [ece2090,ece2010],[]]]
$./schedule <resources2b
found valid ’resources list’
$cat bad_resources2b
[[joe, [ece2090,ece2010,ece3520,ece4420],[[m,8,9]]],
[sam, [ece2010,ece4420],[[tu,9,11],[th,9,11]]],
10
[pete, [ece3520,ece4420],[sat,12,15]],
[randi, [ece2090],[]],
[gwen, [ece2090,ece2010],[]]]
$./schedule <bad_resources2b
syntax error
$cat bad_resources1
[[joe, [ece2090,ece2010,ece3520,ece4420],[]],
[sam, [ece2010,ece4420],[]],
[pete, [ece3520]],
[randi, [ece2090],[]],
[gwen, [ece2090,ece2010],[]]]
$./schedule <bad_resources1
syntax error
6 Notes
• Building of the scanner parser should not generate any shift/reduce
conflicts and/or useless rule or nonterminal warnings.
• The parser should never report that a file is syntactically correct in
addition to reporting an error.
• If we can’t build your scanner/parser with the buildit script, we can’t
grade it.
7 Format of the Electronic Submission
The final zipped archive is to be named <yourname>-sde1.zip, where <yourname>
is your (CU) assigned user name. You will upload this to the Blackboard
assignment prior to the deadline.
The use of gcc, flex and bison should not generate any errors or warn-
ings. The grader will attempt to build and then test your executable. The
grade is based upon a correctly working solution.
The minimal contents of your archive are:
1. A readme.txt file listing the contents of the archive and a brief de-
scription of each file. Include ’the pledge’ here. Here’s the pledge:
11
Pledge:
On my honor I have neither given nor received aid on this
exam.
This means, among other things, that the code you submit is your
code, and it was developed independently. Thus, you should not be
discussing your approach or solution with others in class or anywhere
else.
2. The flex, bison and c sources for your implementation named schedule.*,
where * is in, y and c, respectively. We will use the yyerror.c file
shown in class and in the book, page 180, Figure 6.11 to build the
executable. You should too. Do not redefine this function or include
yyerror.c in your archive.
3. A log of 6 sample uses (3 correct, 3 errors) of the resulting executable for
each element to be recognized in Section 4.1. Name this log schedule.log.
Pick examples other than the ones shown here.
12
- 浏览: 1010608 次
文章分类
最新评论
-
18335864773:
很多公司项目 都在使用pageoffice 来操作word,e ...
用java生成word文档 -
Gozs_cs_dn:
请问下博主, 怎样将sitemesh3.xsd绑定 sitem ...
SiteMesh3配置 -
Rose_06:
springside4.0quick-start.bat报错原因 -
ilemma:
我也是刚参见工作啊,经理让自学这个,有些东西不太懂,能不能发个 ...
Apache Shiro在Web中的应用 -
shanbangyou:
你废了
程序员上班打酱油的方法
发表评论
-
递归归并排序
2016-02-11 20:26 353/* MergeSort.java CSC 225 - ... -
java冒泡排序对布尔类型进行排序
2015-12-11 23:06 647QQ 928900200 程序代写 java不能对 ... -
判断宏是否是“安全”的
2014-11-22 22:54 564给了一系列C++的宏定义,问你一个表达式是否是“安全”的。 ... -
C语言求平均值
2014-11-19 19:14 559木其工作室:QQ928900200 Computing I ... -
C语言连连看
2014-11-18 16:34 604(1)定义一个矩阵,随机产生字符布置地图,例如下面这个4x ... -
The Monty Hall Problem
2014-10-19 12:58 641GNG1106 Lab 3The Monty Hall Pro ... -
java类
2014-10-16 08:27 303木其工作室 qq 928900200 You are ... -
计算机安全
2014-10-07 14:52 436CS461 MP 1: Due Wednesday 09/17 ... -
java星球机器人建模UML
2014-10-06 22:29 400Your task is to design and imp ... -
数据库sql
2014-10-06 22:25 615service QQ 928900200 ... -
C语言 cgi(3)
2014-08-04 09:17 3531cs3157 – Advanced ProgrammingS ... -
C语言 cgi(2)
2014-08-04 09:10 3061Columbia Universitycs3157 – Ad ... -
C语言cgi(1)
2014-08-04 09:08 3351Columbia Universitycs3157 – Ad ... -
c++ input,output
2014-08-04 08:37 473You should be comfortable w ... -
Array of Objects
2014-08-04 08:30 662You should be comfortable w ... -
bat脚本打开网页
2014-07-13 09:54 889start iexplore "http://ww ... -
java 汉诺塔实现自动演示
2014-07-10 11:53 5091、增加计时功能,显 ... -
代写java程序qq:928900200
2014-06-18 12:46 3学校为全面提升学校教学质量,提高管理水平,决定开发一套小型成 ... -
基于MVC的系统代写
2014-06-16 12:13 445人力资源管理系统 完成系统静态页面设计,页面数 ... -
程序设计实践C++ 程序代写(QQ 928900200)
2014-06-10 08:15 316程序设计实践 采用C++ ...
相关推荐
文件指出,GRVA工作组基于2019年修订的框架文件ECE/TRANS/WP.29/2019/34,对新提案进行了讨论,并在2020年的会议中进一步修订了该提案。 此外,文件还提到了1958年协议,这是国际上对于汽车技术法规进行协调的一项...
在2006至2010年的内陆运输委员会工作计划(ECE/TRANS/166/Add.1,项目活动02.4)中,世界论坛的任务被明确为发展、协调和更新法规,以提升车辆性能。提交的工作文件正是为了满足这一授权要求。通过修订,提案旨在使...
Concerning the Adoption of Uniform Technical Prescriptions for Wheeled Vehicles, Equipment and Parts which can be Fitted and/or be Used on Wheeled Vehicles and the Conditions for Reciprocal ...
2. BSIS标准是欧盟在2019年通过的ECE R151法规中的一部分,该法规修订了车辆、设备和零部件的统一技术规定。ECE R151法规是《关于为轮式车辆装备和/或在轮式车辆上使用的设备和零部件采用统一技术规定联合国法规的...
同时,该文档还提及了其他几个具有法律效力的文件,如ECE/TRANS/WP.29/2015/82、ECE/TRANS/WP.29/2020/15和ECE/TRANS/WP.29/2020/26,这些文件可能包含进一步的修订或指导。 车辆外部投影的规定涉及车辆的各个方面...
联合国ECE R155规定是关于车辆网络安全和网络安全管理体系的统一规定。文档中提到的ECE R155是在日内瓦通过的两个历史协议基础上发展起来的,这些协议分别是1958年的《关于采纳统一条件的车辆装备和部件批准和批准...
### ECE R94标准详解 #### 一、概述 ECE R94标准是针对车辆正面碰撞安全的一项国际统一技术规定。该标准由联合国欧洲经济委员会(UNECE)制定,旨在确保车辆在发生正面碰撞时能有效保护车内乘员的安全。ECE R94...
unity手指足球游戏项目源码,源码演示视频地址:https://www.bilibili.com/video/BV1cvg4ecE7R/;unity手指足球游戏项目源码,源码演示视频地址:https://www.bilibili.com/video/BV1cvg4ecE7R/;unity手指足球游戏...
ECE法规目录列表(中英对照) ECE法规目录列表(中英对照)是指1958 Agreement ECE法规的目录列表,该列表提供了车辆设备的法规标准,包括头灯、尾灯、倒车镜、方向指示器、制动灯等车辆设备的法规要求。该列表对...
ECE R79转向认证是联合国欧洲经济委员会(UNECE)发布的一项法规,全称为《关于转向装置方面批准车辆的统一规定》。该法规主要针对自动驾驶汽车的安全标准,特别是涉及车辆转向系统的控制、性能和安全要求。在自动...
ECE R131是一份关于乘用车制动系统型式认证的国际统一规定,涵盖了机动车高级紧急制动系统(AEBS)的认证细节。该规定作为《关于对轮式车辆、可安装和/或用于轮式车辆的装备和部件采用统一技术要求和相互认可基于上述...
ECE R79是关于机动车辆转向装置批准的国际统一规定。该规定旨在为轮式车辆、安装和/或用于轮式车辆的装备和部件的批准提供统一的技术条件,并基于这些条件实现相互认可。 首先,ECE R79规范的背景在于,传统转向...
ECE R13H-乘用车制动系统型式认证的统一规定 知识点详细解析: 1. ECE R13H定义及背景 ECE R13H是一套针对乘用车制动系统的型式认证统一规定。这份规定属于联合国欧洲经济委员会(ECE)制定的技术条例之一,旨在通过...
在现代汽车动力系统的评估中,ECE工况作为一种标准化的测试手段,对于模拟真实道路驾驶条件并评估汽车性能至关重要。ECE工况,即欧洲循环测试工况(European Driving Cycle),被广泛应用于汽车排放测试和动力系统...
ECE R64翻译版是一份涉及轮胎压力监测系统的欧盟法规文件,它规定了轮胎压力监测系统(TPMS)的法规和试验要求。这一文件对于汽车制造商和相关行业来说是十分重要的,因为它定义了关于轮胎压力监测系统认证、技术...
### ECE Statics:UIUC Statics Notes及在电气与计算机工程领域的应用 #### 基础知识(Foundations) 本部分介绍了概率论的基础概念及其在工程应用中的重要性。首先,作者强调了不确定性在实际工程问题中的普遍...
ECE R79法规是欧洲经济委员会(ECE)制定的一套关于车辆辅助驾驶系统(Automatic Driving Assistance Systems, ADAS)的规定,旨在确保这些系统的安全性和有效性。在本压缩包中,"ECE R79法规解读"文档将提供对该...
### ECE021汽车安全标准详解 #### 标题:ECE021 汽车安全标准 - **解读**:此标题指出了一个关键的汽车行业安全标准——ECE021。ECE(European Agreement Concerning the Adoption of Uniform Technical ...