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

正文內(nèi)容

編譯原理課程設(shè)計(jì)報(bào)告c-語(yǔ)言詞法與語(yǔ)法分析器的實(shí)現(xiàn)(參考版)

2024-08-30 09:21本頁(yè)面
  

【正文】 。按照文法規(guī)則對(duì)字符進(jìn)行分類,程序源碼簡(jiǎn)潔明了,基本符合實(shí)驗(yàn)要求。 /* procedure printTree prints a syntax tree to the * listing file using indentation to indicate subtrees */ void printTree( TreeNode * )。 /* Function newExpNode creates a new expression * node for syntax tree construction */ TreeNode * newExpNode(ExpKind)。 endif ifndef _UTIL_H_ define _UTIL_H_ /* Procedure printToken prints a token and its lexeme to the listing file*/ void printToken( TokenType, const char* )。 endif ifndef _SCAN_H_ define _SCAN_H_ define MAXTOKENLEN 40 extern char tokenString[MAXTOKENLEN+1]。 extern int Error。 extern int TraceScan。 } TreeNode。 } attr。 int val。} kind。 union { StmtKind stmt。 int lineno。 define MAXCHILDREN 20 typedef struct treeNode { struct treeNode * child[MAXCHILDREN]。 typedef enum {OpK,ConstK,IdK} ExpKind。/* source line number for listing */ typedef enum {StmtK,ExpK} NodeKind。 extern FILE* listing。 } ifndef _GLOBALS_H_ define _GLOBALS_H_ include include include include ifndef FALSE define FALSE 0 endif ifndef TRUE define TRUE 1 endif /* MAXRESERVED = the number of reserved words */ define MAXRESERVED 6 typedef enum /* bookkeeping tokens */ { ENDFILE,ERROR, /* reserved words */ ELSE,IF,INT,RETURN,VOID,WHILE, /* multicharacter tokens */ ID,NUM, /* special symbols */ PLUS,MINUS,TIMES,OVER,LT,MT,EQ,NEQ,ASSIGN,SEMI,DOT,LPAREN,RPAREN,LZKH,R ZKH,LDKH,RDKH,LZS,RZS,ME,LE } TokenType。 } tree=treesibling。iMAXCHILDREN。 } } else { fprintf(listing,Unknown node kind\n)。 default: fprintf(listing,Unknown ExpNode kind\n)。break。break。 break。 break。 } } else if(treenodekind=ExpK) { switch(tree) { case OpK: fprintf(listing,Op: )。 default: fprintf(listing,Unknown ExpNode kind\n)。 case ArgList: fprintf(listing,ArgList:\n)。 case ParamList: fprintf(listing,ParamList:\n)。 case ArgK: fprintf(listing,Args:\n)。 case CallK: fprintf(listing,Call Function:%s()\n,tree)。 case ComK: fprintf(listing,Compound:\n)。 case StmtList: fprintf(listing,StatementList:\n)。 case LocalDecK: fprintf(listing,Local Declarations:\n)。break。break。break。 case VarDK: fprintf(listing,Var Declaration: )。break。break。 } break。break。break。 case FunDK: fprintf(listing,Function Declaration: )。 case RetK: fprintf(listing,return\n)。break。break。 break。 break。 break。 break。 while(tree!=NULL) { printSpaces()。 } } void printTree(TreeNode * tree) { int i。iindentno。 define INDENT indentno+=2 define UNINDENT indentno=2 static void printSpaces(void) { int i。 */ /*例如: strcpy (str1,china); 作用是將 ”China 這個(gè)字符串拷貝到 str1數(shù)組中 */ } return t。 } else { strcpy(t,s)。 t=(char *)malloc(n)。 if(s==NULL) { return NULL。 } char * copyString(char * s) { int n。 ttype=Void。 t=kind。 } tsibling=NULL。iMAXCHILDREN。 if(t==NULL) { fprintf(listing, Out of memory error at line %d\n,lineno)。 } /* Function newExpNode creates a new expression node for syntax tree construction*/ TreeNode * newExpNode(ExpKind kind) { TreeNode * t = (TreeNode *)malloc(sizeof(TreeNode))。 tlineno=lineno。 tnodekind=StmtK。i++) { tchild[i]=NULL。 } else { for(i=0。 int i。 default: fprintf(listing,Unknown token: %d\n,token)。 case ERROR: fprintf(listing,ERROR: %s\n,tokenString)。 case ID: fprintf(listing,ID, name= %s\n,tokenString)。 case NUM: fprintf(listing,NUM,val= %s\n,tokenString)。 case LE:fprintf(listing,=\n)。 case ME:fprintf(listing,=\n)。 case RZS:fprintf(listing,*/\n)。 case LZS:fprintf(listing,/*\n)。 case RDKH:fprintf(listing,}\n)。 case LDKH:fprintf(listing,{\n)。 case RZKH:fprintf(listing,]\n)。 case LZKH:fprintf(listing,[\n)。 case DOT:fprintf(listing,\n)。 case ASSIGN:fprintf(listing,=\n)。 case NEQ:fprintf(listing,!=\n)。 case MT:fprintf(listing,\n)。 case ENDFILE:fprintf(listing,EOF\n)。 case OVER:fprintf(listing,/\n)。 case TIMES:fprintf(listing,*\n)。 case MINUS:fprintf(listing,\n)。 case PLUS:fprintf(listing,+\n)。\n)。break。break。break。break。 break。 } return currentToken。 } } if (TraceScan) { fprintf(listing,\t%d: ,lineno)。\039。 (tokenStringIndex = MAXTOKENLEN)) tokenString[tokenStringIndex++] = (char) c。 } if ((sav
點(diǎn)擊復(fù)制文檔內(nèi)容
法律信息相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1