欢迎来到天天文库
浏览记录
ID:51619204
大小:663.50 KB
页数:87页
时间:2020-03-26
《编译原理2E全套配套课件龙书 Chapter_six(1).ppt》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、COMPILERCONSTRUCTIONPrinciplesandPracticeKennethC.Louden6.SemanticAnalysisPARTONESemanticAnalysisPhasePurpose:computeadditionalinformationneededforcompilationthatisbeyondthecapabilitiesofContext-FreeGrammarsandStandardParsingAlgorithmsStaticsemanticanalysis:Takeplacepriortoexecution(Su
2、chasbuildingasymboltable、performingtypeinferenceandtypechecking)ClassificationAnalysisofaprogramrequiredbytherulesoftheprogramminglanguagetoestablishitscorrectnessandtoguaranteeproperexecutionAnalysisperformedbyacompilertoenhancetheefficiencyofexecutionofthetranslatedprogramDescription
3、ofthestaticsemanticanalysisAttributegrammaridentifyattributesoflanguageentitiesthatmustbecomputedandtowriteattributeequationsorsemanticrulesthatexpresshowthecomputationofsuchattributesisrelatedtothegrammarrulesofthelanguageWhichismostusefulforlanguagesthatobeytheprincipleofSyntax-Direc
4、tedSemanticsAbstractsyntaxasrepresentedbyanabstractsyntaxtreeImplementationofthestaticsemanticanalysis:NotasclearlyexpressibleasparsingalgorithmsbecauseoftheadditionproblemcausedbythetimingoftheanalysisduringthecompilationprocessMulti-pass(morecommon)orsinglepassleadtototallydifferentp
5、rocessEmphasis:AttributesandattributegrammarsAlgorithmsforattributecomputationThesymboltableDatatypesandtypecheckingAsemanticanalyzerfortheTINYlanguageContentsPartOne6.1AttributesandAttributeGrammars6.2AlgorithmsforAttributeComputationPartTwo6.3TheSymbolTable6.4DataTypesandTypeChecking
6、6.5ASemanticAnalyzerfortheTINYLanguage6.1AttributesandAttributeGrammarsAttributesAnypropertyofaprogramminglanguageconstructsuchasThedatatypeofavariableThevalueofanexpressionThelocationofavariableinmemoryTheobjectcodeofaprocedureThenumberofsignificantdigitsinanumberBindingoftheattribute
7、TheprocessofcomputinganattributeandassociatingitscomputedvaluewiththelanguageconstructinquestionBindingtimeThetimeduringthecompilation/executionprocesswhenthebindingofanattributeoccursBasedonthedifferenceofthebindingtime,attributesisdividedintoStaticattributes(beboundpriortoexecution
此文档下载收益归作者所有