InductivelyDefinedDataConcreteandAbstractsyntax电感定义的数据具体和抽象语法

上传人:ra****d 文档编号:251962291 上传时间:2024-11-11 格式:PPT 页数:11 大小:27.50KB
返回 下载 相关 举报
InductivelyDefinedDataConcreteandAbstractsyntax电感定义的数据具体和抽象语法_第1页
第1页 / 共11页
InductivelyDefinedDataConcreteandAbstractsyntax电感定义的数据具体和抽象语法_第2页
第2页 / 共11页
InductivelyDefinedDataConcreteandAbstractsyntax电感定义的数据具体和抽象语法_第3页
第3页 / 共11页
点击查看更多>>
资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,*,*,*,Inductively Defined DataConcrete and Abstract syntax,Karl Lieberherr,Dont believe the words,Concrete syntax may be more abstract than abstract syntax!,Both,Abstract,and Concrete,Exp:=Identifier,var-exp(id),:=“(lambda“(“Identifier)Exp),lambda-exp(id body),:=“(“Exp“(“Exp“)“),app-exp(rator rand),page 49 of EOPL 2:(replace Exp by Expression,capitalize instead of angle),Both,Abstract,and Concrete,Exp:=Id,var-exp(id),:=“(lambda“(“Id)Exp),lambda-exp(id body),:=“(“Exp“(“Exp“)“),app-exp(rator rand),(define-datatype Exp Exp?,(var-exp,(id Id?),(lambda-exp,(id Id?),(body Exp?),(app-exp,(rator Exp?),(rand Exp?),page 49 of EOPL 2:(Exp by Expression,Id by Identifier,capitalize instead of angle),Represent Id as symbol,Exp:=Id,var-exp(id),:=“(lambda“(“Id)Exp),lambda-exp(id body),:=“(“Exp“(“Exp“)“),app-exp(rator rand),(define-datatype Exp Exp?,(var-exp,(id symbol?),(lambda-exp,(id symbol?),(body Exp?),(app-exp,(rator Exp?),(rand Exp?),page 49 of EOPL 2:(Exp by Expression,Id by Identifier,capitalize instead of angle),cases,(define occurs-free?,(lambda(var exp),(cases Exp e,(var-exp(id)(eqv?id var),(lambda-exp(id body),and(not(eqv?id var),(occurs-free?var body),(app-exp(rator rand)(or ),Exercises for define-datatype,Arithmetic expressions(*(+3 5)7),two arguments only,include evaluator,Nested containers,Exercise:Test data type,Contains in first a Lambda expression lambda-exp and in second an Application app-exp.,Would like something like:,(define-struct Test(,first;type lambda-exp,second;type app-exp,),but with the dynamic checking benefit of define-datatype.,Better Way:variants are first class,Exp:=Id,var-exp(id),:=“(lambda“(“Id)Exp),lambda-exp(id body),:=“(“Exp“(“Exp“)“),app-exp(rator rand),(define-datatype Exp Exp?,(var-exp,(id symbol?),(lambda-exp,(id symbol?),(body Exp?),(app-exp,(rator Exp?),(rand Exp?),Better way:,Exp:VarExp|LambdaExp|AppExp.,VarExp=Id.,LambdaExp=“(lambda“(“Id Exp“).,AppExp=“(“Exp Exp“).,Test=LambdaExp AppExp.,Each non-terminal defines a data type.,Concern analysis,(define(check ac),(local(;Container-Number,;the weight of a container,;effect:the number of capacity violations in a container,(define(weight-container ac),(local(define witems(,weight-loi(Container-contents ac),),(when(witems(Container-capacity ac),(set!violations(+1 violations),witems),;(Listof Item)-Number,;the weight of a list of items,(define(weight-loi l),(foldr+0,(map weight-item l),),;Item-Number,;the weight of an item,(define(weight-item l),(cond,(Simple?l)(Simple-weight l),(Container?l)(weight-container l),(define violations 0),);the number of violations detected,(weight-container ac),violations,),Concerns:,traversal,summing weights,summing violations,Concrete syntax more,Abstract than Abstract Syntax:example,Exp:=Identifier,var-exp(id),:=“(lambda“(“Identifier)List(Exp),lambda-exp(id body),:=“(“Exp“(“List(Exp)“)“),app-exp(rator rand),page 49 of EOPL 2:(replace Exp by Expression,capitalize instead of angle),
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业管理 > 商业计划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!