一、 實驗內容 S語言的編譯程序的詞法分析部分實現 從左到右掃描每行S語言源程序的符號,拼成單詞,換成內部表示(token) 二、 實驗要求 要求實現編譯器的以下功能: 組織源程序的輸入 按規則拼寫單詞,并轉換成二元形式 刪除空格及無用符號(如回車符,字符常數的引號符等) 發現并定位錯誤 建立單詞表、符號表、常數表等文件 三、 實現方法 數據結構 1、 輸入 S語言源程序,為文本文件 2、 輸出 詞法分析程序的運行結果是:產生一個單詞序列文件(token文件)和一個常數表、一個符號表文件,并輸出錯誤信息。 (1) token文件結構 token文件用于存放從S語言源程序中掃描出來的一個個單詞符號的機內表示,其文件結構如下: typedef Struct token { nt label char name[30] int code int addr }token 說明: label:單詞序號; name[30]:單詞本身; code:單詞的編輯; addr:地址,單詞本身保留字時值為-1,為標識符成常數時為大于0常數,即該標識符成常數在符號表中的入口地址。
上傳時間: 2015-04-29
上傳用戶:refent
This text surrounds the development of the electric power SCADA system exactly, aiming at the present condition of the our country electric power charged barbed wire net currently, according to the oneself at the e- lectric power protect the profession after the electricity in seven years of development, design and adjust to try the experience on the scene from following severals carry on the treatise:Is the emergence to the system of SC- ADA and developments to introduce first Carry on the introduction elucidation to applied present condition and the development foregrounds of various terminal equipments communication agreement(rules invite) the next in order Then is the elucidation to the windows the bottom according to the mfc the plait distance environment an- d VC++6.0 plait distance softwares Carry on the more detailed treatise to the realization of the procedure Struct- ure frame and the source code again End is the applied case example give examples.
標簽: the development surrounds electric
上傳時間: 2014-10-28
上傳用戶:liuchee
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <malloc.h> #include <math.h> #include <conio.h> Struct DuLNode{ Struct DuLNode *prior int data Struct DuLNode *next
上傳時間: 2014-01-01
上傳用戶:caiiicc
實習題 [問題描述] 1. 設順序表中的數據元素遞增有序,將插入到順序表的適當位置上,是該表仍然有序。 [輸入] 初始順序表,插入字符。 [輸出] 插入x后線性表的結果 [存儲結構] 采用順序存儲結構 [算法的基本思想] 建立一個遞增順序表,插入一個數值并移動元素,使其仍然有序。 程序如下: #include "iostream.h" #include <malloc.h> #define LIST_INTI_SIZE 100//初始空間大小 typedef Struct SqList
上傳時間: 2014-01-14
上傳用戶:fhzm5658
[輸入] 圖的頂點個數N,圖中頂點之間的關系及起點A和終點B [輸出] 若A到B無路徑,則輸出“There is no path” 否則輸出A到B路徑上個頂點 [存儲結構] 圖采用鄰接矩陣的方式存儲。 [算法的基本思想] 采用廣度優先搜索的方法,從頂點A開始,依次訪問與A鄰接的頂點VA1,VA2,...,VAK, 訪問遍之后,若沒有訪問B,則繼續訪問與VA1鄰接的頂點VA11,VA12,...,VA1M,再訪問與VA2鄰接頂點...,如此下去,直至找到B,最先到達B點的路徑,一定是邊數最少的路徑。實現時采用隊列記錄被訪問過的頂點。每次訪問與隊頭頂點相鄰接的頂點,然后將隊頭頂點從隊列中刪去。若隊空,則說明到不存在通路。在訪問頂點過程中,每次把當前頂點的序號作為與其鄰接的未訪問的頂點的前驅頂點記錄下來,以便輸出時回溯。 #include<stdio.h> int number //隊列類型 typedef Struct{ int q[20]
標簽: 輸入
上傳時間: 2015-11-16
上傳用戶:ma1301115706
2.[問題描述] 編寫遞歸算法,在二叉樹中求位于先序序列中第K個位置的結點 [輸入] 按照先序序列的順序輸入該結點的內容。其輸入abd eh cf i g 。輸入要求的位置 [輸出] 若二叉樹不空,按先序序列輸出,求出所求位置的結點 [存儲結構] 采用二叉表存儲 [算法的基本思想] 采用遞歸方法建立和遍歷二叉樹。首先建立二叉樹的根結點,然后建立其左右子樹,直到空子樹為止,先序遍歷二叉樹時,先遍厲左子樹,后遍厲右子樹,最后訪問根結點并計算出二叉樹中葉子結點的數目和第K個位置的結點 #include<stdio.h> #include<malloc.h> Struct node{ char info Struct node*llink,*rlink } typedef Struct node NODE
上傳時間: 2014-01-13
上傳用戶:zm7516678
[問題描述] 在二叉排序樹中查找關鍵字為KEY的記錄 [輸入] 有序表輸入要查找元素的關鍵字 [輸出] 查找成功是即可顯示查找成功 #include <stdlib.h> #include <stdio.h> typedef int KeyType typedef Struct{
上傳時間: 2015-11-16
上傳用戶:erkuizhang
學會對文件的記錄鎖定,及解鎖。#include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { int fd int i Struct { char name[20] uint ID int age } myrec fd =open("name", O_RDWR|O_CREAT, 0755) if (fd == -1) return -1 printf("Input your name:") scanf("%s", myrec.name) printf("Inpute your ID :") scanf("%d", &myrec.ID) printf("Input your age :") scanf("%d", &myrec.age) lseek(fd, 0,SEEK_END) lockf(fd, 1, 0) write(fd, (void *)&myrec, sizeof(myrec)) lockf(fd, 0 ,0) return 0 } 執行命令cc lock.c –o lock.out Chmod +x lock.out ./lock.out
標簽: 記錄
上傳時間: 2016-01-04
上傳用戶:亞亞娟娟123
經典數據結構中較難的平衡二叉排序樹的操作,考慮到較多同學都需要,特此上傳,c++實現,需要做異質樹的自行把Struct改為class既可。
上傳時間: 2016-02-17
上傳用戶:cxl274287265
數據結構(嚴慰敏)配套純c代碼實驗十 typedef int InfoType // 定義其它數據項的類型 typedef int KeyType // 定義RedType類型的關鍵字為整型 Struct RedType // 記錄類型(同c10-1.h) { KeyType key // 關鍵字項 InfoType otherinfo // 其它數據項 } typedef char KeysType // 定義關鍵字類型為字符型 #include"c1.h" #include"c10-3.h" void InitList(SLList &L,RedType D[],int n) { // 初始化靜態鏈表L(把數組D中的數據存于L中) char c[MAX_NUM_OF_KEY],c1[MAX_NUM_OF_KEY] int i,j,max=D[0].key //
標簽: typedef int InfoType KeyType
上傳時間: 2016-03-03
上傳用戶:2404