A Reusable Object-Oriented Approach to Formal Spec

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

AReusableObject-OrientedApproachtoFormalSpecificationsofProgrammingLanguages0DUMDQ0HUQLN0LWMD/HQLa(QLV$YGLaDX^HYL`9LOMHP#XPHUUniversityofMariborFacultyofElectricalEngineeringandComputerScienceSmetanova17,2000Maribor,Sloveniamarjan.mernik@uni-mb.siRESUME.ABSTRACT.Formalmethodsfordescribingprogramminglanguagesemanticsareanexcellenttoolforprogramminglanguagedesignanddevelopment.However,theyarenotwidelyusedsincetheyarenotmodular,extensibleandreusable.Inthepaperanewmodular,extensibleandreusableapproachforspecifyingprogramminglanguageswithattributegrammarsispresented.Theconceptsofobject-orientedprogramming,i.e.templates,multipleinheritance,andobject-orientedimplementationofsemanticdomains,areintegratedwithattributegrammars.Withtheproposedapproachalanguagedesignerhasthechancetodesignincrementallyalanguageorreusesomefragmentsfromotherprogramminglanguagespecifications.TheproposedapproachhasbeenimplementedinourcompilergeneratortoolLISAver.2.0.MOTS-CLES:KEYWORDS:languagespecifications,reusability,extensibility,attributegrammars,compilergenerators2Documentnumérique.Vol.1-n°1/19971IntroductionCompilerconstructionisoftenmentionedasoneofthefewreallysystematicallymanageddisciplines.Thereisalongtraditionofproducingcompilers,underlyingtheoriesarewellunderstoodandthereexistmanyapplicationgeneratorswhichautomaticallyproduceacompileroraninterpreterfromtheformalprogramminglanguagespecification.Formalmethodsforprogramminglanguagedescriptionalsoserveasatoolforprogramminglanguagedevelopmentanddesign.Theprogramminglanguageswhichhavebeendesignedwithoneofthevariousformalmethodshaveabettersyntaxandsemantics,lessexceptionsandareeasiertolearn.However,despiteoftheobviousadvantages,noneofthecurrentlymostwidelyusedformalmethodsforprogramminglanguagedescription,suchasdenotationalsemantics,operationalsemantics,axiomaticsemantics,orattributegrammars,havegainedmorepopularityandgeneraluse.Somereasonsforthisare:semanticsismuchmoredifficulttodescribethanthesyntax,andsemanticsdescriptionisnoteasytoread.Weareconvincedthattherealproblemwiththeseformalmethodsisthelackofmodularity,extensibilityandreusability.Sinceprogramminglanguagedesignisaniterativeprocess,designersneedpartialdescriptionsthatcanbeeasilyreused,extendedandmodified.Inthepaperanewapproachtomodularity,extensibilityandreusabilityofattributegrammarsispresented.AttributegrammarshavebeenintroducedbyD.E.Knuth[KNU68]andsincethenareproventobeusefulinspecifyingthesemanticsofprogramminglanguages,inautomaticconstructingofcompilers/interpreters,inspecifyingandgeneratinginteractiveprogrammingenvironmentsandinmanyotherareas.Attributegrammarsareageneralizationofcontext-freegrammarsinwhicheachsymbolhasanassociatedsetofattributesthatcarrysemanticinformation,andwitheachproductionasetofsemanticruleswithattributecomputationisassociated.Inattributegrammarssemanticsisgiveninadeclarativeratherthananoperationalnotation.However,ordinaryattributenotationhasdeficiencieswhichbecomeapparentinspecificationsforrealprogramminglanguages.Suchspecificationsarelarge,unstructuredandarehardtounderstand,modifyandmaintain.Therefore,inrecentyears,theresearchonattributegrammarshasshiftedfromtheoreticalinvestigationstoimprovingattributegrammarsasamethodology,andtodesigningsystemswithmajoremphasisonpragmaticissues[PAA95].Inthispaperanewapproachthatovercomesthedrawbacksofordinaryattributegrammarsispresented.Theconceptsfromobject-orientedprogramming,i.e.template,multipleinheritance,andobject-orientedimplementationofsemanticdomains,areintegratedwithattributegrammars.Withtemplatesweareabletodescribethesemanticruleswhichareindependentofgrammarproductionrules.Specificationswithtemplatesarereusable,shorterandeasiertoreadandmaintain.Withmultipleinheritanceweareabletoorganizespecificationsinsuchawaythatspecificationscanbeinheritedandspecializedfromancestorspecifications.Multipleattributegrammarinheritancesupportsreusabilityandextensibilityofattributegrammars.Withobject-orientedimplementationofsemanticdomainsweareabletoreusevarioussemanticdomainsinimplementingdifferentprogramminglanguagesbyinheritanceoraggregation.Thepaperisanextensionofthepaper[MER98].Reusablesyntaxandsemanticspecificationsarepresentedinsections2and3.Furtheron,insection4,ourimplementationandexperiencearebrieflydescribed.Insection5relatedworkisDocumentnumérique.Vol.1-n°1/19973described.Itisfollowedbytheconclusioninsection7.ApartofspecificationsforPLMlanguageispresentedinappendix.Weassumethatthereaderisfamiliarwithattributegrammars.2ReusablesyntaxspecificationsInformalmethodsforprogramminglanguagedescription(regularexpressions,BNFandattributegrammars)wearelookingforcomponentswhichcanbereusedinthespecificationforanotherprogramminglanguage.InformalspecificationsofprogramminglanguageitiseasytonoticethatthemainpartofsuchaspecificationconsistsofthesemanticspecificationandthemuchsmallerpartconsistsofBNFandregularexpressions.Therefore,ourattentioninsearchingforreusablecomponentswasmainlyfocusedonsemanticspecifications.Sincesemanticscannotbedefinedwithoutthesyntax,alsothere

1 / 30
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功