SemanticanalysisParsingonlyverifiesthattheprogramconsistsoftokensarrangedinasyntactically-validcombination,wenowmoveontosemanticanalysis,wherewedelvedeepertocheckwhethertheyformasensiblesetofinstructionsintheprogramminglanguage.Foraprogramtobesemanticallycorrect,allvariables,functions,classes,etc.areproperlydefined,expressionsandvariablesareusedinwaysthatrespectthetypesystem,accesscontrolisn’tviolated,andsoon.Semanticanalysisisthenext-to-lastphaseofthefrontendandthecompiler’slastchancetoweedoutincorrectprograms.Weneedtoensuretheprogramiswell-formedenoughtocontinueontothenextphasewherewegeneratecode.semanticanalysisandsymboltableAlargepartofsemanticanalysisconsistsoftrackingvariable/function/typedeclarations.Asweentereachnewidentifierinoursymboltable,weneedtorecordthetypeinformationofthedeclaration.Then,aswecontinueparsingtherestoftheprogram,wemakesurethatthetypeofeachidentifierandexpressionisrespectedintermsoftheoperationsbeingperformedExamplesofthethingswecheckinthesemanticanalysisphase..Thetypeoftheright-sideexpressionofanassignmentstatementshouldmatchthetypeoftheleft-side,andtheleft-sideneedstobeaproperlydeclaredandassignableidentifier(i.e.notsomesortofconstant).Theparametersofafunctionshouldmatchtheargumentsofafunctioncallinbothnumberandtype.Thelanguagemayrequirethatidentifiersareunique,disallowingaglobalvariableandfunctionofthesamename.Theoperandstomultiplicationoperationwillneedtobeofnumerictype,perhapseventheexactsametypedependingonthestrictnessofthelanguage.Asweencounteridentifiersinaprogram,weneedtodetermineiftheidentifierisaccessibleatthatpointintheprogram.ThisiscalledscopecheckingOneadditionalissueinsemanticanalysisisdealingwithscopes..Ascopeisasectionofprogramtextenclosedbybasicprogramdelimiters,e.g.,{}inC,orbegin-endinPascal.Manylanguagesallownestedscopesthatarescopesdefinedwithinotherscopes.Thescopedefinedbytheinnermostsuchunitiscalledthecurrentscope.Thescopedefinedbythecurrentscopeandbyanyenclosingprogramunitsareknownasopenscopes.Anyotherscopeisa...