编译原理课件PPT 第3章.pptCHAPTER3LEXICALANALYSISSection0Approachestoimplementalexicalanalyzer1、SimpleapproachConstructadiagramthatillustratesthestructureofthetokensofthesourcelanguage,andthentohand-translatethediagramintoaprogramforfindingtokensNotes:EfficientlexicalanalyzerscanbeproducedinthismannerCHAPTER3LEXICALANALYSISSection0Approachestoimplementalexicalanalyzer2、Pattern-directedprogrammingapproachPatternMatchingtechniqueSpecifyanddesignprogramthatexecuteactionstriggeredbypatternsinstringsIntroduceapattern-pilerforLexcangenerateanefficientfiniteautomationrecognizerfortheregularexpressionsCHAPTER3LEXICALANALYSISpiler1、MaintaskToreadtheinputcharactersToproduceasequenceoftokensusedbytheparserforsyntaxanalysisAsanassistantofparserCHAPTER3LEXICALANALYSISSection1Theroleofthelexicalanalyzer2、InteractionoflexicalanalyzerwithparserLexicalanalyzerParserSymboltableSourceprogramtokenGetnexttokenCHAPTER3LEXICALANALYSISSection1Theroleofthelexicalanalyzer3、ProcessesinlexicalanalyzersScanningPre-pilerwithsourceprogramAlinenumbercanbeassociatedwithanerrormessageLexicalanalysisCHAPTER3LEXICALANALYSISSection1Theroleofthelexicalanalyzer4、TermsofthelexicalanalyzerTokenTypesofwordsinsourceprogramKeywords,operators,identifiers,constants,literalstrings,punctuationsymbols(mas,semicolons)LexemeActualwordsinsourceprogramPatternAruledescribingthesetoflexemesthatcanrepresentaparticulartokeninsourceprogramRelation{<.<=,>,>=,==,<>}CHAPTER3LEXICALANALYSISSection1Theroleofthelexicalanalyzer5、AttributesforTokensApointertothesymbol-=M*C**2<id,pointertosymbol-tableentryforE><assign_op,><id,pointertosymbol-tableentryforM><multi_op,><id,pointertosymbol-tableentryforC><exp_op,><num,integervalue2>CHAPTER3LEXICALANALYSISSection1Theroleofthelexicalanalyzer6、LexicalErrorsDeletinganextraneouscharacterInsertingamissingcharacterReplacinganincorrectcharacterbyacorrectcharacterTransposingtwoadjacentcharacters(suchas,fi=>if)Pre-scanningCHAPTER3LEXICALANALYSISSection1Thero
编译原理课件PPT 第3章 来自淘豆网www.taodocs.com转载请标明出处.