编译原理实验
程序核心代码和注释:
public void analyzer()
{
//***************************
//循环读取grammar.txt
//***************************
/*此处代码略*/
//***************************
//循环读取 lengh.txt
//***************************
/*此处代码略*/
//****************************
// 读入文件,进行语法分析
//
//****************************
string strReadFile;
strReadFile="input.txt";
myTextRead.myStreamReader=new StreamReader(strReadFile);
string strBufferText;
int wid =0;
Console.WriteLine("分析读入程序(记号ID):\n");
do
{
strBufferText =myTextRead.myStreamReader.ReadLine();
if(strBufferText==null)
break;
foreach (String subString in strBufferText.Split())
{
if(subString!="")
{
int ll;
if(subString!=null)
{
ll= subString.Length; //每一个长度
}
else
{
break;
}
int a=ll+1;
char[] b = new char[a];
StringReader sr = new StringReader(subString);
sr.Read(b, 0, ll); //把substring 读到char[]数组里
int sort=(int)b[0];
// word[i] 和 wordNum[i]对应
11
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库编译原理_实验报告(11)在线全文阅读。
相关推荐: