⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 get_code.cpp

📁 操作系统实验,实现词法分析,内含源文件的输入与扫描.
💻 CPP
字号:
#include "get_code.h"
#include<fstream.h>
#include<iostream.h>

LCode* InPutCode()//将代码读入内存(链表)
{
	ifstream fin("panda.txt");
	LCode* head;//存放代码的链表
	LCode* pEnd;
	LCode* pS;
	pS=new LCode;
	head=NULL;
	pEnd=pS;
	if(!fin.eof())
	{
		pS->cCode=fin.get();
	}
	while(!fin.eof())
	{
		if(head==NULL)
		{
			head=pS;
			head->prior=NULL;
		}
		else
		{
			pEnd->next=pS;
			pS->prior=pEnd;
		}
		pEnd=pS;
		pS=new LCode;
		pS->cCode=fin.get();
	}
	pS=new LCode;
	pEnd->next=pS;
	pS->prior=pEnd;
	pS->next=NULL;
	pS->cCode=NULL;//此时用做标志位
	pEnd=pS;
	return head;
}
char GetCode(LCode* & pS)//获取代码链表的一个字符
{
	if((pS->next)==NULL)
	{
		return NULL;
	}
	else
	{
		char cCode=pS->cCode;
		pS=pS->next;
		return cCode;
	}
}
char GetBC(LCode* & pS,char& cCode)//处理空格
{
	while(cCode==' ')
	{
		cCode=pS->cCode;
		pS=pS->next;
	}
	return cCode;
}
LCode* Retract(LCode* & pS)//搜索指示器回调一个字符
{
	pS=pS->prior;
	return pS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -