编译原理本科试卷A.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:9 大小:279KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

编译原理本科试卷A.doc

编译原理本科试卷A.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

《编译原理》试卷A第页共NUMPAGES9页姓名学号学院班级座位号(密封线内不答题)……………………………………………………密………………………………………………封………………………………………线……………………………………线………………………………………_____________________…诚信应考,考试作弊将带来严重后果!华南理工大学期末考试《编译原理》试卷A注意事项:1.考前请将密封线内填写清楚;2.所有答案请直接答在试卷上;3.考试形式:闭卷;4.本试卷共大题,满分100分,考试时间120分钟。题号一二三四五总分得分评卷人Note:WhetherEnglishorChinesedoesn’timpactyourscore.Fillintheblanks(18%)a.Normally,Acomplierconsistsofanumberofphases.TheyareScannerGrammarparser,____Semanticanalyzer_____,___SourceCodeOptimizer___,CodeGenerator,and__targetcodeoptimizer_________________.b.ThelogicalunitsthescannergeneratesarecalledTokens.Foramodernprogramminglanguage,therearefivetypesoftoken.Theyare__Identifier__,_______ReservedWords________,_____Number_____________,____________________,________________.c.BasedonthefollowingCsourcecodefragmentintgets(char*s){if(s==NULL){printf(“illegalpointparameter\n”);return-1;}return0;}Pleaseanswer:a)“int”isa___________________b)“printf”isa_________________c)“s”isa(an)_________________d)“==”isa____________________e)“0”isa_____________________d.AgrammarGusuallyincludesfourcomponents,theyare_______________,__________________,_______________,and_____________________.(TermsTranslation,12%)PleasegiveabriefexplanationtothefollowingtermsincompilersciencedomainCompiler——Sourcecode——Scanner——Tokens——Terminalsymbol——AmbiguousGrammar——(Scanning;20%)(a)(10%)ConstructanNFAthatrecognizesthesamelanguageasdefinedbythefollowingregularexpression:(a*ba*b)*ba*(b)(10%)Usingthesubsetconstruction,converttheNFAintoaDFA.abA={0,1,2,5}BCB={2}BDC={3,6,7,8}EFD={3}DFE={3,7,8}EFF={1,2,4,5}BC4.(LLparsing;25%)ConsiderthefollowinggrammarG(S):S->number|ListList->(Seq)Seq->Seq,S|SWherenumberand“,”areterminalsymbols,andtheotherssymbolsarenon-terminal.(a)(7%)Pleasewritetheleft-mostderivationforsentence“(4,(34))”(b)[8%]PleaseconvertthegrammarGintoaLL(1)grammarG1byremovetheleftrecursion.(c)[10%]BasedonyourLL(1)grammarG1,pleasecalculatetheFOL