• 大小: 1.4MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-01
  • 语言: 其他
  • 标签: IF-ELSE  LR方法  

资源简介

IF-ELSE条件语句的翻译程序设计(LR方法、输出三地址表示)

资源截图

代码片段和文件信息

#include“declare.h“
#include
#include

//...............................ListManager................................//
ListManager::ListManager(){
//初始化关键字表
keyList.push_back(“begin“) ;
keyList.push_back(“call“) ;
keyList.push_back(“const“) ;
keyList.push_back(“do“) ;
keyList.push_back(“end“) ;
keyList.push_back(“if“) ;
keyList.push_back(“true“) ;
keyList.push_back(“false“) ;
keyList.push_back(“else“) ;
keyList.push_back(“odd“) ;
keyList.push_back(“procedure“) ;
keyList.push_back(“read“) ;
keyList.push_back(“then“) ;
keyList.push_back(“var“) ;
keyList.push_back(“while“) ;
keyList.push_back(“write“) ;
//初始化操作符表
optrList.push_back(‘+‘) ;
optrList.push_back(‘-‘) ;
optrList.push_back(‘*‘) ;
optrList.push_back(‘/‘) ;
optrList.push_back(‘(‘) ;
optrList.push_back(‘)‘) ;
optrList.push_back(‘=‘) ;
optrList.push_back(‘>‘) ;
optrList.push_back(‘<‘) ;
optrList.push_back(‘|‘) ;
optrList.push_back(‘&‘) ;
optrList.push_back(‘!‘) ;
//初始化分界符表
splitList.push_back(‘‘) ;
splitList.push_back(‘.‘) ;
splitList.push_back(‘#‘) ;
splitList.push_back(‘;‘) ;
}

int ListManager::containsKeyWord(string str){
//判断是否是关键字
for(int i = 0;i if(str == keyList.at(i)){
return KEY ;
}
}
return -1 ;
}

int ListManager::containsOptr(char ch){
//判断是否是一个操作符
for(int i = 0;i   if(ch == optrList.at(i)){
return OPTR ; 
}
}
return -1 ; 
}

int ListManager::containsSplit(char ch){
//判断是否是分界符
for(int i = 0;i if(ch == splitList.at(i)){
return SPLIT ; 
}
}
return -1 ;
}

//..........functions............//
string GetFileName(){
string fileName ;
cout<<“******Please input the file name you wanto compile it!******“<  cin>>fileName ;
cin.ignore() ;
return fileName ;
}

string GetNextLine(ifstream& fin){
string line ;
if(getline(finline)){
return line ;
}
return “0_NO_0“; //用来判断是否到末尾
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件         95  2010-01-07 20:01  CompilerPro1\test.txt

     文件        104  2010-01-07 20:46  CompilerPro1\test1.txt

     文件        207  2010-01-07 22:09  CompilerPro1\lexout.txt

     文件       1072  2010-01-07 20:50  CompilerPro1\lr_ds.h

     文件        847  2010-01-07 14:03  CompilerPro1\declare.h

     文件       2073  2010-01-07 18:41  CompilerPro1\declare.cpp

     文件      54784  2010-01-10 18:37  CompilerPro1\CompileExp1.opt

     文件        530  2009-11-07 10:02  CompilerPro1\CompileExp1.dsw

     文件       1437  2010-01-07 22:09  CompilerPro1\CompileExp1.plg

     文件         71  2010-01-07 22:09  CompilerPro1\dd.txt

     文件      74752  2010-01-10 18:37  CompilerPro1\CompileExp1.ncb

     文件       4655  2010-01-07 11:46  CompilerPro1\CompileExp1.dsp

     文件     123904  2010-01-07 22:09  CompilerPro1\Debug\vc60.idb

     文件     192512  2010-01-07 22:09  CompilerPro1\Debug\vc60.pdb

     文件    3390720  2010-01-07 20:51  CompilerPro1\Debug\CompileExp1.pch

     文件     387002  2010-01-07 22:09  CompilerPro1\Debug\lr_ds_impl.obj

     文件     379738  2010-01-07 20:51  CompilerPro1\Debug\MainThread.obj

     文件     749671  2010-01-07 22:09  CompilerPro1\Debug\CompileExp1.exe

     文件    1696768  2010-01-07 22:09  CompilerPro1\Debug\CompileExp1.pdb

     文件      44166  2010-01-07 20:51  CompilerPro1\Debug\sem_impl.obj

     文件          0  2009-11-19 13:01  CompilerPro1\Debug\out.txt

     文件    1167756  2010-01-07 22:09  CompilerPro1\Debug\CompileExp1.ilk

     文件     197348  2010-01-07 18:41  CompilerPro1\Debug\declare.obj

     文件          0  2010-01-07 21:18  CompilerPro1\Debug\lexout.txt

     文件       7393  2010-01-07 15:19  CompilerPro1\MainThread.cpp

     文件        357  2010-01-07 20:48  CompilerPro1\sem_impl.cpp

     文件        103  2010-01-07 21:03  CompilerPro1\test2.txt

     文件      35315  2010-01-07 21:07  CompilerPro1\lr_ds_impl.cpp

     目录          0  2010-01-04 23:02  CompilerPro1\Debug

     目录          0  2010-01-04 23:02  CompilerPro1

............此处省略3个文件信息

评论

共有 条评论