91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 405KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-26
  • 語言: 其他
  • 標簽: 編譯原理??YACC??LEX??

資源簡介

自己做編譯課程設計寫的一個很簡單的C編譯器,用的是LEX+YACC寫的,方法比較新,由于時間的關系寫的不是很完善,但是要擴充的話比較容易。壓縮包中附LEX&YACC的語言詳解,相信對于對編譯有興趣的人有些幫助。

資源截圖

代碼片段和文件信息

#include?“com.h“
Table?table(?Table?tp?int?level)
?{
??int?i;
??Table?newTemp?=?(Table)?malloc(?sizeof(?struct?table?)?);
??newTemp->previous?=?tp;
??newTemp->level?=?level;?
??for(?i?=?0;?i???{
???newTemp->buckets[i]?=?NULL;
??}
??if?(tp)
???newTemp->all?=?tp->all;
??return?newTemp;
?}

?struct?symbol?*?install(char?*name?Table?*tpp?int?level?int?sclass)
?{
??Table?tp?=?*tpp;
??struct?entry?*p;
??int?len;
??unsigned?h?=?name[0]?&?(HASHSIZE?-?1);
??if?(level?>?0?&&?tp->level????tp?=?*tpp?=?table(tp?level);
??currentTable?=?tp;
??p?=?(struct?entry?*)?malloc(?sizeof(?struct?entry?)?);
??len?=?strlen(?name?);
??p->sym.name?=?(char?*)?malloc(?len?*?sizeof(?char?)?);
??strcpy(?p->sym.name?name?);
??p->sym.scope?=?level;
??p->sym.up?=?tp->all;
??p->sym.sclass?=?sclass;
??tp->all?=?&p->sym;
??p->link?=?tp->buckets[h];
??tp->buckets[h]?=?p;
??return?&p->sym;
?}

?struct?symbol?*?lookup(char?*name?Table?tp)?{
??struct?entry?*p;
??unsigned?h?=?name[0]?&?(HASHSIZE-1);
??if(?tp?==?NULL?)?return?NULL;
??do
???for?(p?=?tp->buckets[h];?p;?p?=?p->link?)
???{
????if?(?p?!=?NULL?&&?strcmp(name?p->sym.name)?==?0?)
?????return?&p->sym;
???}
??while?((tp?=?tp->previous)?!=?NULL);
??return?NULL;
?}

?void?enterscope()?{
??currentLevel++;
?}
?void?exitscope()?{
??if?(currentTable->level?==?currentLevel)?{
???Table?tt?=?currentTable;
???currentTable?=?currentTable->previous;
???free(?tt?);
??}
??--currentLevel;
?}
?Symbol?makeSym(?char?*text?)
?{
??int?len;
??Symbol?temp?=?(Symbol)?malloc(?sizeof(?struct?symbol?)?);
??len?=?strlen(?text?);
??temp->name?=?(char?*)?malloc(?len?*?sizeof(?char?)?);
??strcpy(?temp->name?text?);
??temp->scope?=?currentLevel;
??return?temp;
?}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????45540??2009-09-10?16:21??compile\c

?????文件???????1782??2009-09-10?01:41??compile\com.c

?????文件???????1976??2009-09-10?01:59??compile\com.h

?????文件????????247??2009-09-10?01:33??compile\common.h

?????文件????????303??2009-09-10?17:14??compile\hello.c

?????文件?????763771??2009-09-09?09:45??compile\Lex&Yacc.pdf

?????文件???????1410??2009-09-10?01:40??compile\lex.l

?????文件??????50222??2009-09-10?16:20??compile\lex.yy.c

?????文件?????????63??2009-09-09?18:22??compile\new?2

?????文件????????679??2009-09-19?12:32??compile\result.txt

?????文件??????33877??2009-09-10?14:14??compile\syntax.y

?????文件??????37101??2009-09-09?12:39??compile\syntax.y~

?????文件?????100362??2009-09-10?16:20??compile\y.tab.c

?????文件???????3078??2009-09-10?16:20??compile\y.tab.h

?????目錄??????????0??2010-01-19?14:06??compile

-----------?---------??----------?-----??----

??????????????1040411????????????????????15


評論

共有 條評論