freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

編譯原理語義分析論(編輯修改稿)

2025-02-02 21:53 本頁面
 

【文章內(nèi)容簡介】 ifthen 語句嵌套賦值語句 ifthenelse 語句嵌套 ifthen 語句嵌套賦值語句 循環(huán)語句 賦值語句 復(fù)合語句 程序 語義分析產(chǎn)生的語義四元式文件( ): 12 100(:=,6,,j) 101(:=,3,,m) 102(+,j,m,T1) 103(:=,T1,,n) 104(j=,n,3,106) 105(j,,,111) 106(j,n,5,108) 107(j,,,111) 108(,j,1,T2) 109(:=,T2,,j) 110(j,,,115) 111(j,n,10,113) 112(j,,,115) 113(*,j,4,T3) 114(:=,T3,,j) 115(j,a,b,117) 116(j,,,120) 117(+,j,1,T4) 118(:=,T4,,j) 119(j,,,115) 經(jīng)測試,該語義分析程序正確執(zhí)行,并產(chǎn)生了正確的四元式中間代碼。 13 程序源代碼: **************************詞法分析器代碼( ) ************************ !C:\Python27\python FileName: 39。39。39。\ author: zeadom date: 20220330 39。39。39。 import os import ch = code = key_words={program:1,begin:2,end:3,var:4,integer:5,\ if:6,then:7,else:8,do:9,while:10,\ int:11,and:12,or:13,not:14,\ +:17,:18,(:19,):20,=:21,:22,\ :23,。:24,::25,:=:26,:27,\ *:28,/:29,.:30,=:31,=:32,:33} def isLetter(): global ch if ch==None: return False else: return () def isDigit(): global ch if ch==None: return False else: return () def concat(): global code global ch code = code+ch def getchar(l,i): if len(l)=i or i0: return None 14 else: return l[i] def getstr(): global code global key_words global ll type = 0 state = None str = 。 if code==None: str = u(0,+code+,%d)%ll elif code in key_words: if(key_words[code]==25): str = error code in line %d\n%ll str = str + error code : else: str= u(+key_words[code]+u,+code+,%d)%ll elif (): str= (16,+code+,%d)%ll else: str= (15,+code+,%d)%ll return str ll = 0 flag = []。 if __name__==__main__: src = r outfile = r if not (src): print cannot open file,src else: inputf = open(src,r) outputf = open(outfile,w) annotation = 0 ll = 0 for line in inputf: ll=ll+1 i = 0 l = len(line) 15 while il: if i=len(line): break code = ch = getchar(line,i) i = i+1 if annotation==1: if ch==* and getchar(line,i)!=None and getchar(line,i)==39。/39。: str = annotation end in line %d\n%ll (str) annotation = 0 i=i+1 continue if ch==39。/39。 and getchar(line,i)!=None and getchar(line,i)==39。/39。: (line annotation in line %d\n%ll) i = i+1 break if ch==None: break elif ch==/ and getchar(line,i)!=None and getchar(line,i)==39。*39。: str = annotation start in line %d\n%ll (str) i=i+1 annotation = 1 elif ch== or ch==\n or ch==39。\t39。: continue elif isLetter(): while isLetter() or isDigit(): concat() ch = getchar(line,i) i=i+1 i=i1 str = getstr() str = str+\n (str) continue elif isDigit(): while isDigit(): concat() ch = getchar(line,i) i=i+1 i=i1 str = getstr() str = str+\n 16 (str) continue elif ch in key_words: concat() ch = getchar(line,i) i=i+1 if ch!=None and (code+ch) in key_words: concat() str = getstr() str = str+\n (str) else: i=i1 str = getstr() str = str+\n (str) else: str = error in line %d\n%ll (str) (error code +ch+\n)。 **************************資源文件( ) ******************************** ifndef RESOURCE_H_ZEADOM define RESOURCE_H_ZEADOM define $program 1 define $begin 2 define $end 3 define $var 4 define $integer 5 define $if 6 define $then 7 define $else 8 define $do 9 define $while 10 define $int 11 define $and 12 define $or 13 define $not 14 define $flag 15 define $num 16 define $add 17 define $sub 18 define $left 19 17 define $right 20 define $eq 21 define $gt 22 define $lt 23 define $ 24 define $copy 26 define $ma 27 define $mul 28 define $div 29 define $point 30 define $loe 31 define $goe 32 define $ne 33 endif ****************************語義分析頭文件( ) ************************ ifndef ZEADOM_SEMANTIC_H define ZEADOM_SEMANTIC_H include string using namespace std。 includeiostream include fstream include sstream int quad,varT。 int Nextquad() { return quad++。 } string NextT() { varT++。 string temp = T。 stringstream ss。 ssvarT。 temp = temp+ ()。 return temp。 } void semantic_init() { 18 varT=0。 quad=100。 } struct siyuanshi { string op,par1,par2,result。 bool hasop,haspar1,haspar2,hasresult。 bool isjump。 int jump。 siyuanshi() { op = par1 = par2 = result = 。 hasop = haspar1 = haspar2 = hasresult = false。 jump = 0。 isjump=false。 } void setop(string arg) { op = arg。 hasop = true。 } void setpar1(string arg) { par1 = arg。 haspar1 = true。 } void setpar2(string arg) { par2 = arg。 haspar2 = true。 } void setresult(string arg) { result = arg。 hasresult = true。 } void setjump(int arg) 19 { jump = arg。 isjump = true。 }
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1