/
2KazutakaMatsudaandMengWangprograminversiontechniques,obtainaconsisten 2KazutakaMatsudaandMengWangprograminversiontechniques,obtainaconsisten

2KazutakaMatsudaandMengWangprograminversiontechniques,obtainaconsisten - PDF document

olivia-moreira
olivia-moreira . @olivia-moreira
Follow
366 views
Uploaded On 2016-07-13

2KazutakaMatsudaandMengWangprograminversiontechniques,obtainaconsisten - PPT Presentation

x3300 nest2line x3300 text x3300 text x3300 pprPe2ThesuxPinpprPstandsforparenthesespprPOnetext1pprPSube1e2text x3300 groupppre1 x3300 nest2line x3300 text ID: 402200

㌀ nest2(line ㌀ text"-" ㌀ text"" ㌀ pprPe2))--ThesuxPinpprPstandsforparentheses.pprPOne=text"1"pprP(Sube1e2)=text"(" ㌀ group(ppre1 ㌀ nest2(line ㌀ text"-

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "2KazutakaMatsudaandMengWangprograminvers..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

2KazutakaMatsudaandMengWangprograminversiontechniques,obtainaconsistentparser.We,asusual,manu-allyimplementedaparserandapretty-printerforthelanguage,butwiththehopethatwe,andmanyotherswhoreadthispaper,willnotneedtodoitagainfortheirownlanguageimplementations.Priortothiswork,therehasbeenarichbodyofliteratureonexploringcorrectness-by-constructiontechniquestoautomaticallygenerateoneorbothprogramsoftheprinter/parserpair,notably[2,4,17].Wehaveintentionallyomittedthepre x\pretty-"fromthementioningofprintersherebecausefewoftheexistingworkisactuallyproducingpretty-printersinthesenseofHughes[10]andWadler[22].1Tobemorepreciseaboutwhatwemeanby\prettiness",letusconsiderasubtractionlanguagee::=1je1�e2thathasaconstant(1)andaleft-associativebinaryoperator(�).WerepresentthesyntaxwiththefollowingASTdatatype.dataE=OnejSubEEUsingthelanguageweproposeinthispaper,whichisbasedonWadler'sli-brary[10],onecande neapretty-printerasbelow.pprOne=text"1"ppr(Sube1e2)=group(ppre1 ㌀ nest2(line ㌀ text"-" ㌀ text"" ㌀ pprPe2))--ThesuxPinpprPstandsforparentheses.pprPOne=text"1"pprP(Sube1e2)=text"(" ㌀ group(ppre1 ㌀ nest2(line ㌀ text"-" ㌀ text"" ㌀ pprPe2)) ㌀ text")"Thepretty-printinglibraryfunctionsareshowninslantsansserif.Roughlyspeak-ing,textsconvertsastringstoalayout,d1   d2isanin xbinaryoperatorthatconcatenatestwolayoutsd1andd2,whichbindslooserthanpre xapplications,andlinestartsanewline,butitsbehaviorcanbea ectedbysurroundingnestandgroupapplications:nestndinsertsn-spacesaftereachlinesind,andgroupdsmartlychoosesbetweenthelayoutdandotherlayoutsderivablefromdbyse-lectivelyinterpretinglinesassinglespaces.(Inthispaper,wewrite\space"forthespacecharacterandwrite\whitespace"forthespacecharacterandthenew-linecharacter.Otherkindsofspacessuchashorizontaltabsarenotdiscussedastheydonotyieldnewinsight.)Thefunctionpprpretty-printsSub(SubOneOne)(SubOneOne)as1-1-(1-1)or1-1-(1-1)or1-1-(1-1)dependingonthescreenwidththatisusedtorendertheresult.This ne-grainedcontrolfromusersoverbracketing,spacingandindentationisclearlybeyondanytechniquebasedonmechanicaltraversalsofASTs,whichislikelytorigidly 1TheSynsystem[2]iscapableofhandlingnon-contextuallayouts,whichcanbeseenasalimitedformofprettiness. 4KazutakaMatsudaandMengWanglanguageprovides,andthetranslationfromthesurfacelanguagetothecorelanguageistheidentityoperationinthiscase.Therefore,wefocusonthecoresysteminthissectionandpostponethediscussionofthesurfacelanguagetoSect.4.Asastart,let'srevisitthepretty-printerpprde nedintheprevioussec-tion.Ifthefunctionisinvertedasitis,wecanhopefornomorethanaparserthatonlyrecognizesprettystrings.Thisisneitherthefaultoffunctionpprnoroftheinverter:apretty-printerppr(correctly)producesonlyprettylayouts,andaninvertercannotinventinformationthatisnotalreadycarriedbythefunctiontobeinverted.Toremedythisinformationmismatch,weinstrumentthepretty-printerwithadditionalinformationaboutnon-prettybutneverthelessvalidlayouts.2.1IntroducingUglinessReinterpretationofline.Acommonsourceofprettinessisthecleverinterpre-tationoflineseitherasasinglespaceoranicelyindentednewlinedependingontheenvironment.Thise ectcanbesimplyeliminatedbyreinterpretinglineasoneormorewhitespaces.Usingthisnewinterpretationinthederivationofaparserenablesustoparsecertainnon-prettylayouts.Forexample,nowtheinverseofthepretty-printercanparsethefollowingstrings.1-1or1-1Thesestringsdonotsatisfyournotionofprettinessde nedbyppr,andwillnotbeproducedbythepretty-printer,butwillbeacceptedbythegeneratedparserthroughthereinterpretationoflines.Alsonotethatthisreinterpretationalsomeansthatwecansafelyignoregroupandnestduringinversion,becausetheirsolepurposeistoa ectthebehavioroflines.Still,thissolutionaloneisnotenough.Stringslike1-1and(1)-((1))remainunparsable:thepretty-printerhasdictatedthatthereisonlyasinglespacebetweentheoperatorandthesecondoperandbyusingtext""insteadofline,andthatthereshouldn'tberedundantparentheses.Weneedto ndawaytoalterthesebehaviorsinparsingwithoutlosingpretty-printing.BiasedChoice.Toannotatepretty-printerswithinformationaboutnon-prettylayouts,weintroducethechoiceoperator + .Inpretty-printingtheoperatorbehavesase1 + e2=e1,ignoringthenon-prettyalternativee2;inparserderiva-tiontheoperatorisinterpretedasanondeterministicchoice,whichacceptsbothbranches.Theoperator + bindslooserthan   andhasthefollowingalgebraicproperties.Associativitye1 + (e2 + e3)=(e1 + e2) + e3Distributivity-L(e1 + e2) ㌀ e3=e1 ㌀ e3 + e2 ㌀ e3Distributivity-Re1 ㌀ (e2 + e2)=e1 ㌀ e2 + e1 ㌀ e3Forexample,onecande nevariantsof(white)spaceswiththechoiceoperatorasfollows.nil=text"" + space--(zero-or-morewhitespacesinparsing)space=(text"" + text"\n") ㌀ nil--(one-or-morewhitespacesinparsing) 6KazutakaMatsudaandMengWang prog::=rule1;:::;rulenrule::=fp1:::pn=ep::=xjCp1:::pne::=text"string"je1 ㌀ e2jlinejnestnejgroupe(Wadler'sCombinators)je1 + e2(BiasedChoice)jfx1:::xn(TreelessCall) Fig.2.Syntaxofthecorelanguage:frangesoverfunction,Crangesoverconstructors,xandxisrangeovervariablesandnrangeovernaturalnumbers.presentation).Ppr!Ppr f$1gj"("NilPprNil")"f$3gPpr !1fOnegjPprLine0"-"Space0PprPfSub$1$5g:::Thecorrectnessoftheparserconstructioncomesfromourpreviouswork[15].SinceFliPprproducesaCFGwithactions,usershavethechoiceofusinganyparsergeneratorthatsupportsfullCFG.Inourimplementation,weuseFrostetal.[8]'stop-downparser.3CoreLanguageandParserConstructionInthissection,wegivetheformalde nitionofthecorelanguageofFliPpr,anddiscussparserconstructionbyprograminversion.3.1SyntaxandSemanticsFigure2showsthesyntaxofourcorelanguage,a rst-orderfunctionallanguagesimilartoonefoundintheintroduction.WeincludeWadler'spretty-printingcombinators[22]andthebiasedchoiceasprimitiveoperators,andplacetworestrictionsforlaterinversion:{Functioncallsmustbetreeless[21]:theytakeonlyvariablesasarguments.{Variableusemustbelinear:everyboundvariableinaruleisusedexactlyonceontheright-handside.Anotableexceptioniswith + .Fore1 + e2,thetwobranchesaresupposedtobebothlinear.Thus,theycontainthesamesetoffreevariables.Forexample,assumingfislinear,thengx=fx + fxislinear,buthx=line + fxandkx=line + text"s"arenot.Forsimplicity,weoftenomittheruleseparator\;"ifnoconfusionwouldarise.Weusevectornotationexforasequencex1;:::;xn.Weabusethenotationtowritefexforfx1:::xn.Theformalpretty-printingsemanticsofthelanguageisshowninFig.3.Wewrite�`e+vifunderenvironment�,expressioneevaluatestovaluev.Values 8KazutakaMatsudaandMengWang3.2ParserConstructionbyInversionToinvertprogramswritteninthecorelanguage,we rstlyperformasemantic-preservingtransformationtoremovethepretty-printingcombinators,andobtainasyntaxthatisrecognizablebyourgrammar-basedinversionsystem[15].ConvertingtoNondeterministicProgramsThisstepisdoneby\forgettingsmartlayoutingmechanism",throughthefollowingrewritingrules.text"s"�!"s"nestne�!egroupe�!eline�!spacee1   e2�!e1++e2e1 + e2�!e1?e2Here,spaceisarewrittenversion(accordingtotherulesabove)ofitsde nitioninSect.2,i.e.thefunctionde nedbyspace=(""?"\n")++nilnil=""?spaceandtheoperator?isanondeterministicchoice.Theformalsemanticsoftheobtainednondeterministicprogramsisde nedstraightforwardlybyaddingthefollowingrules. �`"s"+"s"�`ei+v �`e1?e2+vi=1;2f�`ei+vigi=1;2 �`e1++e2+v1++v2Theirbehaviorsof"s",?and++arethesameasthereinterpretationsoftext"s", + and   ,respectively;weusedi erentsymbolstoclarifythattheconversiondiscardsthepretty-printingsemantics.Notethat,sincethelanguageislinearandtreeless,thecall-timechoiceandtherun-timechoice[19]donotdi er.Wewritef ande astherewrittenversionoffande.Thefollowinglemmastatesthattherewritingissemanticpreserving.Lemma1(SemanticPreservation).�`e+NDsi �`e +s.utGrammar-BasedInversionTherewrittenprogramscanbeprocessedtoob-tainagrammarwithactions4thatcomputestheinverseoftherewrittenprogrambyusinggrammar-basedinversion[15].Thebasicideaoftheinversionistoreadaruleofaprogramasaproductionruleofagrammar,andtousesemanticactionstotrackhowvariables(i.e.,inputs)arepassed.Intheinversion,weconstructtwosortsofnon-terminals:Ffforfunctionsf andEeforexpressionse .Forafunctionf thattakest1;:::;tnandreturnss,Ffisusedtoparsestrings,andthesemanticactionreturnsoriginalinputs(t1;:::;tn).Foranexpressione suchthat�`e +s,Eeisusedtoparsestrings,andthesemanticactionreturnstheoriginalenvironment�.ThegenerationoftheproductionrulesandsemanticsactionsarepresentedinFig.5.ThegrammarinSect.2isasimpli edversionofthegrammarobtainedbythisgeneration. 4Intheoriginalpaper[15],transformationsonparsetrees(ormoreprecisely,deriva-tiontreesofproductions)areused,insteadofsemanticactions. 10KazutakaMatsudaandMengWang4.1ProblemswithProgrammingintheCoreLanguageLetusconsiderextendingthesubtractionlanguagewithdivisionandvariables.dataE=jDivEEjVarStringRecallthatweusedtwomutuallyrecursivefunctionspprandpprPtocontrolbracketingissuesaround\-".Ingeneral,whentherearemanyoperatorswithdi erentprecedencelevels,itsucestouseafunctionforeachprecedencelevel.Forexample,assuming\-"hasprecedence-level6and\/"hasprecedence-level7astheydoinHaskell,apretty-printercanbewrittenasfollows.pprx=ppr5x--5isthelowestprecedencelevel:::ppr 5(Subxy)=:::ppr6x:::text"-":::ppr7y:::--(1)ppr 5(Divxy)=:::ppr5x:::text"/":::ppr6y:::--(2):::ppr 6(Subxy)=text"(" ㌀ nil ㌀ :::{-theRHSof(1)-}::: ㌀ nil ㌀ text")"ppr 6(Divxy)=:::{-theRHSof(2)-}::::::ppr 7(Subxy)=text"(" ㌀ nil ㌀ :::{-theRHSof(1)-}::: ㌀ nil ㌀ text")"ppr 7(Divxy)=text"(" ㌀ nil ㌀ :::{-theRHSof(2)-}::: ㌀ nil ㌀ text")"Therearealotofundesirablerepetitionsintheabovede nitionlargelyduetothetreelessrestriction.Anotherproblemthatitisnon-trivialtoseparatevariablenameswithpre-de nednames.Forexample,letusconsiderpretty-printingforVarx.Onemaybetemptedtowriteppr (Varx)=textxbutaparserderivedfromtheabovewillparse\-"asVar"-",becausethereisnoinformationintheabovede nitionthatspeci esvalidvariablenames.Wecanimprovethepretty-printerasfollows.ppr (Varx)=fxf('a':x)=text"a" ㌀ gx:::f('z':x)=text"z" ㌀ gxg[]=text""g('a':x)=text"a" ㌀ gx:::g('z':x)=text"z" ㌀ gxNotethatstringsarerepresentedaslistsofcharactersasinHaskell.Thisfunctionppr ispartialandintentionallyunde nedforVar"-".Inthisde nition,wehavesuccessfullyrestrictedvariablenamestorangeoverlower-caseEnglishalphabets,butinaverycumbersomeway.4.2AnOverviewToreducetheprogramminge ort,weproposeasurfacelanguage,whichhasrelaxedlinearityandtreelessnessrestrictions,andisequippedwithashorthandnotationforexpressingnameranges.Inthislanguage,apretty-printerforthe 12KazutakaMatsudaandMengWang ;�;`e: ;�;fx:g`x: ;�;;`x:�(x) ;�;;`c:St;�;`e:Doc ;�;`nestne:Docf;�;i`ei:Docg1inop=text"s";group;( ㌀ );line ;�;U1ini`ope1:::en:Docf;�;`ei:Docgi=1;2 ;�;`e1 + e2:Doc ;�;fx:ASTg`text(xasr):Docf;�;;`ei:Stg1inf;�;`eb:gb=t;f ;�;`ifprede1:::enthenetelseef:f;�;i`ei:ig1in(f)=1!!n!Doc ;�;U1ini`fe1:::en:Doc `fp1:::pn=e (f)=1!!n!Doc9�;1;:::;nf�;i`pi:ig1indom(�)U1infv(pi);�;U1ini`e:Doc `fp1:::pn=e �;`p: �(x)=St �;;`x:St2fAST;Docg �;fx:g`x:f�;i`pi:g1in2fAST;Stg �;U1ini`Cp1:::pn: Fig.7.Typingrules:here]representsdisjointunion.operationsfoundintheprevioussubsection.Usedasarguments,suchconstantscanbeeliminatedatcompilationtimethroughpartialevaluation;wecallsuchconstantsstaticinformation.Theifbranchingsinspectstaticinformation,andareeliminablestaticallyaswell.Weuseatypesystemtodistinguishstaticinformation(oftypeSt)fromotherkindsofvaluessuchastheinputASTs(oftypeAST)andthepretty-printingresults(oftypeDoc).Thetypesystemensuresthatstaticinformationareeliminablethroughpartial-evaluation,andvariableusesarelinear.Formally,primitivetypesandfunctiontypesarede nedby:::=ASTjStjDoc::=1!!n!Typingjudgment;�;`e:readsthatunderfunction-typeenvironment,non-lineartypeenvironment�andlineartypeenvironment,ehastype.Similarly,wede ne�;`p:and`fp1:::pn=eforpatternsanddeclarations.Figure7showsthetypingrules,whicharemostlyself-explanatory.Notably,theusesofvariablesoftypeASTandDochavetobelinear,asdictatedbytherules.ThelinearityrestrictionofASTvariablesisinheritedfromthecorelanguage,whilethatofDocvariablesisrequiredforthecorrectnessoffusion;itisknownthatthedeforestationisnotcorrectfornon-linearandnon-deterministicprograms[1].Aprogramisassumedtohaveadistinguishedentrypointfunction 14KazutakaMatsudaandMengWangasbelow.pprx=go5x:::go 5(Subxy)=:::go5x:::go6y:::go 5(Divxy)=:::go6x:::go7y::::::go 6(Subxy)=:::go5x:::go6y:::go 6(Divxy)=par(:::go6x:::go7y:::):::go 7(Subxy)=par(:::go5x:::go6y:::)go 7(Divxy)=par(:::go6x:::go7y:::)Roughlyspeaking,thankstothetypeAST!Docoftheentrypointfunction,thetypesystemguaranteesthateverySt-typeexpressionmustbeaconstantitselforapartofsomeconstantobtainedbypattern-matching,andthuscaneliminatedbypartial-evaluation.FusingFunctionstoObtain1-tierProgramsWeshowthetransforma-tionof2-tieredprogramsto1-tieredprograms,withtheunderstandingthattheprocedurecanbeappliediterativelytotransformm-tieredprogramsto1-tieredprograms.Thetransformationisdonebydeforestation[21].Roughlyspeaking,defor-estation(or,supercompilation[20]5)performscall-by-nameevaluationofexpres-sions;butinsteadofcomputingavalue,itproducesanewexpressionthathasthesamebehaviorastheoriginalonebutwithintermediatedatastructureselim-inated.Withoutlossofgenerality,weassumethatASTargumentsappearbeforeDocargumentsinfunctioncalls.ThedeforestationprocedureDJeKisde nedasfollows.{DJope1:::enK=opDJe1K:::DJenK,whereoprangesovertext"s",(   ),line,nesti,groupand( + ).{DJfexeeK=feeexez.AssumingexhavetypeAST(recallthatonlyvariableshavetypeAST),eehavetypeDoc,andfezgarethefreevariablesinee,thenewlygeneratedfunctionfeeisde nedasfeeepez=DJe[ey7!ee]Kforeachcorrespondingrulefepey=einthede nitionoff(withproper -renaming).Here,wedonotrepeatedlygeneraterulesoffeeiftheyarealreadygenerated(uptorenamingofthefreevariablesinee).Theaboveprocedurefollowsfromtheoriginalone[21],andissimpli edtosuittherestrictedsurfacelanguage.Theprocedureterminatesifthenumberoffunctionsfeegeneratedinthelattercaseis nite.ByusingDJeK,wereplaceeverytier-2rulefepey=ewithfepey=DJeK.Example1.Wedeforestthepretty-printerde nedinSect.4.2. 5Becauseofthelinearity,Wadler'sdeforestation[21]and(positive)supercompila-tion[20]coincideforthesurfacelanguage. 16KazutakaMatsudaandMengWangWeleaveoutnestandtext"s"forsimplicity.Inthedatatype,weuseEVarbothforvariablesandfunctioncallstoavoidambiguityingrammars.Theoverallprincipleofourpretty-printingistoinsertbreaksafter=,andbefore�and,with2-spaceindentation.Westartwithlistsofrules,andinsertseparatorswithoptionalwhitespacesnil   text";"   line0betweenindividualrules.pprx=pprRulesxpprRules[]=nilpprRules(r:rs)=nil ㌀ pRulesrrs ㌀ nilpRulesr0[]=pprRuler0pRulesr0(r:rs)=pprRuler0 ㌀ nil ㌀ text";" ㌀ line0 ㌀ pRulesrrsForeachrule,itsright-handsidemaystartanewline.pprRule(Rulefpse)=group(varf ㌀ space ㌀ pprPatsps ㌀ space0 ㌀ text"=" ㌀ nest4(line0 ㌀ pprExpe))varx=text(xas[a-z][ a-zA-Z0-9]*'*)Alistofpatternsistreatedinasimilarwaytoalistofrules.pprPats[]=text""pprPats(p:ps)=pPatsppspPatsp0[]=pprPatp0pPatsp0(p:ps)=pprPatp0 ㌀ space ㌀ pPatsppsRedundantparenthesesinpatternsareadmissibletothegeneratedparser,butwillnotbeproducedbythepretty-printer.pprPatp=manyPars(pprPat p)pprPat (PVarx)=varxpprPat (PConc[])=concpprPat (PConc(p:ps))=par(conc ㌀ space ㌀ pPatspps)conf=text(xas[A-Z][ a-zA-Z0-9]*'*)Expressionsareprintedaccordingtotheprecedence-levelsandassociativitiesoftheoperators.pprExpe=go4egoie=manyPars(go ie)go i(EConc[])=concgo i(EConc(e:es))=parIf(i9)(conc ㌀ space ㌀ pExpsees)go i(EOpOAlte1e2)=parIf(i5)(group(go5e1 ㌀ nest2(line0 ㌀ text" ㌀ space0 ㌀ go4e2)))go i(EOpOCate1e2)=parIf(i6)(group(go6e1 ㌀ nest2(line0 ㌀ text�" ㌀ space0 ㌀ go5e2)))go i(EVarf[])=varfgo i(EVarf(e:es))=parIf(i9)(varf ㌀ space ㌀ pExpsees)Finally,alistofexpressionsprintedinasimilarwaytoalistofpatterns.pExpse0[]=go9e0pExpse0(e:es)=go9e0 ㌀ space ㌀ pExpsees 18KazutakaMatsudaandMengWangintheoperands,andde nefx7!vg]fx7!vg=fx7!vg.Thisnaivesolutionworkse ectivelyforXML,becausethenumberofpossibleASTsisusually nite.However,ingeneralparsingbecomesundecidablewithnon-linearuseofASTvariables,asshownin[13](Theorem4.4).Thus,forthiskindofnon-linearuses,amethodthatchecksthe nitenessofparsetreesisrequired.Thenon-linearityofDocvalueshasnon-trivialinteractionwithnondetermin-ism.Intheabsenceoflinearity,thecall-by-valueandthecall-by-nameseman-ticsmayceasetocoincide.Thisisaproblembecausecall-by-valueissuitableforgrammar-basedinversion[15],butcall-by-nameissuitablefordeforestation[18].WealsoneedtoresorttogrammarsbeyondCFGs,whichmayposedicultiesininversion.Itisachallengingproblemto ndasweetspotbetweenobtainingecientinversesandsupportingfusioninthesurfacelanguage.7RelatedWorkDi erentapproacheshavebeenproposedtosimultaneouslyderiveaparserandaprinterfromsomeintermediatedescriptions.Inparticularly,onecouldstartfromanannotatedCFGspeci cationtoderivebothaparserandapretty-printer[2].Comparedtothesesystems,FliPpro ers nercontroloverpretty-printing.Inparticular,weareabletodealwithcontextualinformationandtode neauxiliaryfunctionslikeparinprinting,whichismadeconvenientlyavailablebythesurfacelanguage.Otherapproachesincludeinvertiblesyntaxdescriptions[17]basedoninvertibleprogramming,andBNFC-meta[4]basedonmetaprogramming.Bothworkrecognizestheimportanceofgoodprinting,butisnotabletosupportpretty-printing.Therearealsogeneral-purposebidirectionallanguages[3,6,11]thatinthe-orycanbeusedtobuildtheprinter/parserpairfromthede nitionofoneofthem.Notablyquotientlenses[7]aredesignedtoincludearepresentativeofaquotientbeforeperformingbidirectionalconversions;inourcase,roughlyspeak-ingthisquotientoperationistheerasureofredundantwhitespacesandparen-theses.However,thereisagapbetweenthetheoreticalpossibilityandpracti-callyexecution.Inparticular,thepretty-printinglibrariesofWadler[22]andHughes[10]arenotonlyuser-friendlybutalsohighlyoptimized.Moreover,forecientparsingwehavetoperformwhole-programanalysis(asinconventionalparsingalgorithmslikeLR-k)orusesophisticateddatastructuresandmemo-ization[8,16].Itisnotobvioushowthesesophisticatedimplementationscanbepackedintoabidirectionalprogram.Inourapproach,weavoidthisproblembyusinggrammar-basedinversion[15],whichgeneratesgrammarsandoutsourcestheparsingalgorithmstoselectedparsergenerators.Therearealotofdiscussionsonhowtomakedeforestation(supercompila-tion)terminate(e.g.,[12])forTuring-completelanguages.Theseapproachesuseconditionstogiveupfusion,andreusethealready-generateddeforestedfunc-tions.Asaresult,theseapproachesmayfailtofusesomefunctions,andthusarenotsuitableforourpurpose.Thecompletenessofdeforestation,inthesensewhetherallthenestedcallsarefusedaway,hasnotbeenthefocusofstudyin 20KazutakaMatsudaandMengWang4.Duregard,J.,Jansson,P.:EmbeddedParserGenerators.In:Haskell2011:Proceed-ingsofthe2011ACMSIGPLANHaskellSymposium,pp.107{117.ACM(2011)5.Duregard,J.,Jansson,P.,Wang,M.:Feat:FunctionalEnumerationofAlgebraicTypes.In:Haskell2012:Proceedingsofthe2012ACMSIGPLANHaskellSympo-sium,pp61{72.ACM(2012)6.Foster,J.N.,Greenwald,M.B.,Moore,J.T.,Pierce,B.C.,Schmitt,A.:CombinatorsforBidirectionalTreeTransformations:ALinguisticApproachtotheView-UpdateProblem.ACMTrans.Program.Lang.Syst.29(3)(2007)7.Foster,J.N.,Pilkiewicz,A.,Pierce,B.C.:QuotientLenses.In:ICFP2008:Pro-ceedingsofthe13thACMSIGPLANInternationalConferenceonFunctionalPro-gramming,pp.383{396.ACM(2008)8.Frost,R.A.,Ha z,R.,Callaghan,P.:ParserCombinatorsforAmbiguousLeft-RecursiveGrammars.In:Hudak,P.,Warren,D.S.(eds.)PADL.LNCS,vol.4902,pp167{181,Springer(2008)9.Fulop,Z.,Vogler,H.:Syntax-DirectedSemantics:FormalModelsBasedonTreeTransducers.1stedn.Springer-VerlagNewYork,Inc.,Secaucus,NJ,USA(1998)10.Hughes,J.:TheDesignofaPretty-PrintingLibrary.In:Jeuring,J.,Meijer,E.(eds.)AdvancedFunctionalProgramming.LNCS,vol.925,pp.53{96,Springer(1995)11.Jansson,P.,Jeuring,J.:PolytypicDataConversionPrograms.Sci.Comput.Program.43(1),35{75(2002)12.Jonsson,P.A.,Nordlander,J.:PositiveSupercompilationforaHigherOrderCall-by-ValueLanguage.In:POPL2009:Proceedingsofthe36thACMSIGPLAN-SIGACTSymposiumonPrinciplesofProgrammingLanguages,pp.277{288,ACM(2009)13.Kobayashi,N.,Tabuchi,N.,Unno,H.:Higher-OrderMulti-ParameterTreeTrans-ducersandRecursionSchemesforProgramVeri cation.In:POPL2010:Proceed-ingsofthe37thACMSIGPLAN-SIGACTSymposiumonPrinciplesofProgram-mingLanguages,pp.495{508,ACM(2010)14.Kuhnemann,A.,Gluck,R.,Kakehi,K.:RelatingAccumulativeandNon-AccumulativeFunctionalPrograms.In:Middeldorp,A.(ed.)RTA.LNCS,vol.2051,pp.154{168,Springer(2001)15.Matsuda,K.,Mu,S.C.,Hu,Z.,Takeichi,M.:AGrammar-BasedApproachtoInvertiblePrograms.In:Gordon,A.D.(ed.)ESOP.LNCS,vol.6012,pp.448{467,Springer(2010)16.Might,M.,Darais,D.,Spiewak,D.:ParsingwithDerivatives:AFunctionalPearl.In:ICFP2011:Proceedingofthe16thACMSIGPLANInternationalConferenceonFunctionalProgramming,pp.189{195,ACM(2011)17.Rendel,T.,Ostermann,K.:InvertibleSyntaxDescriptions:UnifyingParsingandPrettyPrinting.In:Haskell2010:Proceedingsofthe2010ACMSIGPLANHaskellSymposium,pp.1{12,ACM(2010)18.Sands,D.:ProvingtheCorrectnessofRecursion-BasedAutomaticProgramTrans-formations.Theor.Comput.Sci.167(1&2),193{233(1996)19.Sndergaard,H.,Sestoft,P.:Non-DeterminisminFunctionalLanguages.Comput.J.35(5),514{523(1992)20.Srensen,M.H.,Gluck,R.,Jones,N.D.:APositiveSupercompiler.J.Funct.Program.6(6),811{838(1996)21.Wadler,P.:Deforestation:TransformingProgramstoEliminateTrees.Theor.Comput.Sci.73(2),231{248(1990)22.Wadler,P.:APrettierPrinter.InGibbons,J.,deMoor,O.,eds.:TheFunofProgramming.PalgraveMacmillan(2003)

Related Contents


Next Show more