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

  • 大小: 341.1 KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-08-09
  • 語言: 其他
  • 標簽:

資源簡介

用c寫的一個比較簡單的編譯器。。

資源截圖

代碼片段和文件信息

/****************************************************/
/*?File:?analyze.c??????????????????????????????????*/
/*?Semantic?analyzer?implementation */
/*?for?the?C_Minus?compiler */
/****************************************************/

#include?“globals.h“
#include?“util.h“
#include?“parse.h“
#include?“symtab.h“
#include?“analyze.h“

/*?counter?for?variable?memory?locations?*/
static?int?location?=?0;

/*?current?symble?table?*/
static?Symtab?*?pTable;
static?FunEntry?*?pFun;

/*?procedure?traverse?is?a?generic?recursive
?*?syntax?tree?traversal?routine:
?*?it?applies?preProc?in?preorder?and?postProc?
?*?in?postorder?to?tree?pointed?to?by?t
?*/
static?void?traverse(TreeNode?*?t?
?void?(*?preProc)?(TreeNode?*)
?void?(*?postProc)?(TreeNode?*))
{?
if?(t?!=?NULL)
{?
int?i;
preProc(t);
for?(i=0;?i? traverse(t->child[i]?preProc?postProc);
postProc(t);
traverse(t->sibling?preProc?postProc);
}
}

/*?nullProc?is?a?do-nothing?procedure?to?
?*?generate?preorder-only?or?postorder-only
?*?traversals?from?traverse
?*/
static?void?nullpreProc(TreeNode?*?t)
{?
if?(t?==?NULL)?return;
else?if?(t->nodekind?==?Dec)?{
switch?(t->kind.dec)
{
case?FunDefK:
pFun?=?Lookup_Fun(t->attr.name);
break;
case?CompK:
pTable?=?t->attr.table;
break;
}
}
}

static?void?nullpostProc(TreeNode?*?t)
{?
if?(t?==?NULL?||?pTable?==?NULL)?return;
else?if?(t->nodekind?==?Dec?&&?t->kind.dec?==?CompK)
pTable?=?pTable->parent;
}

/*?procedure?insertNode?inserts?
?*?identifiers?stored?in?t?into?
?*?the?symbol?table?
?*/
static?void?insertNode(TreeNode?*?t)
{?
switch?(t->nodekind)
{?
????case?Dec:
switch?(t->kind.dec)
{?
case?FunDecK:
if?(Lookup_Fun(t->attr.name)?==?NULL)
Insert_Fun(t->attr.name?t->type?t->child[0]);
break;
case?FunDefK:
if?(Lookup_Fun(t->attr.name)?==?NULL)
pFun?=?Insert_Fun(t->attr.name?t->type?t->child[0]);
break;
case?VarK:
{
ValEntry?Entry;
TreeNode?*?child;
for?(child?=?t->child[0];?child?!=?NULL;?child?=?child->sibling)?{
if?(child->nodekind?==?Exp?&&?child->kind.exp?==?IdK)?{
if?(Lookup_Var(pTable?pFun?child->attr.name?&Entry)?!=?pTable->nestlevel)
if?(child->child[0]?==?NULL)
Insert_Var(pTable?child->attr.name?t->type?1);
else
Insert_Var(pTable?child->attr.name?t->type?child->child[0]->attr.val.i);
}
else?if?(child->nodekind?==?Stmt?&&?child->kind.stmt?==?AssignK)?{
if?(Lookup_Var(pTable?pFun?child->child[0]->attr.name?&Entry)?!=?pTable->nestlevel)
if?(child->child[0]->child[0]?==?NULL)
Insert_Var(pTable?child->child[0]->attr.name?t->type?1);
else
Insert_Var(pTable?child->child[0]->attr.name?t->type?child->child[0]->child[0]->attr.val.i);
}
}
}
break;
case?CompK:
pTable?=?Createtab(pTable?pFun);
if?(pTable==NULL)

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

?????文件???????7926??2003-06-23?02:15??源程序\analyze.c

?????文件???????2027??2003-06-22?22:45??源程序\C_Minus.c

?????文件??????18369??2003-06-24?16:24??源程序\CodeGen.c

?????文件??????44677??2003-06-24?17:07??源程序\parse.c

?????文件??????13563??2003-06-24?17:07??源程序\scan.c

?????文件???????6706??2003-06-23?00:15??源程序\symtab.c

?????文件???????6974??2003-06-24?15:38??源程序\util.c

?????文件???????5219??2003-06-22?20:27??源程序\C_Minus.dsp

?????文件????????539??2003-06-22?20:16??源程序\C_Minus.dsw

?????文件????????578??2003-06-23?00:15??源程序\analyze.h

?????文件???????1312??2003-06-23?00:16??源程序\CodeGen.h

?????文件???????3413??2003-06-24?12:40??源程序\globals.h

?????文件???????2052??2003-06-24?17:07??源程序\parse.h

?????文件???????1242??2003-06-24?17:07??源程序\scan.h

?????文件???????1452??2003-06-23?00:16??源程序\symtab.h

?????文件????????650??2003-06-23?00:13??源程序\util.h

?????文件???????3111??2003-06-23?00:16??源程序\scan.l

?????文件?????148480??2004-06-14?14:38??源程序\C_Minus.ncb

?????文件????????797??2003-06-14?01:33??源程序\Lex&Yacc.pgp

?????文件????????268??2003-06-24?17:07??源程序\Lex&Yacc.pgw

?????文件????????248??2004-06-14?14:37??源程序\C_Minus.plg

?????文件???????1214??2003-06-22?20:14??源程序\ReadMe.txt

?????文件??????33176??2003-06-24?17:07??源程序\parse.v

?????文件??????15029??2003-06-24?17:07??源程序\scan.v

?????文件??????11797??2003-06-24?17:07??源程序\parse.y

?????文件??????41984??2004-06-14?14:37??源程序\Debug\vc60.idb

?????文件??????53248??2004-06-14?13:03??源程序\Debug\vc60.pdb

?????文件??????25135??2004-06-14?13:03??源程序\Debug\util.obj

?????文件??????13546??2004-06-14?13:03??源程序\Debug\symtab.obj

?????文件??????12786??2004-06-14?13:03??源程序\Debug\scan.obj

............此處省略13個文件信息

評論

共有 條評論