cr_parse.cpp
来自「自己写的关于编译原理的实验报告的源代码」· C++ 代码 · 共 65 行
CPP
65 行
//**********************************************************
// CR_PARSE.CPP
// Coco/R C++ Support Library.
// Author: Frankie Arzu <farzu@uvg.edu.gt>
//
// Jun 12, 1996 Version 1.06
// Many fixes and suggestions thanks to
// Pat Terry <cspt@cs.ru.ac.za>
//**********************************************************
#include "cr_parse.hpp"
#include "cr_error.hpp"
#include <stdio.h>
const int NSETBITS = 16;
CRParser::CRParser(AbsScanner *S, CRError *E)
{
if (!E || !S) {
fprintf(stderr, "CRParser::CRParser: No Scanner or No Error Mgr\n");
exit(1);
}
Scanner = S;
Error = E;
Sym = 0;
}
void CRParser::Parse()
{
printf("Abstract CRParser::Parse() called\n"); exit(1);
}
void CRParser::GenError(int ErrorNo)
//++++ GenError is supposed to be "private" for Coco/R only. If a user calls
//++++ it directly, that is fine, but there is no consistency check performed
{
Error->StoreErr(ErrorNo, Scanner->NextSym);
}
void CRParser::SynError(int ErrorNo)
//++++ SynError is for users. Note that we check for error number
//++++ clashes. If the numbers are too small, we simply make them bigger!
{
if (ErrorNo <= Error->MinUserError) ErrorNo = Error->MinUserError;
Error->StoreErr(ErrorNo, Scanner->NextSym);
}
void CRParser::SemError(int ErrorNo)
//++++ SemError is for users. Note that we check for error number
//++++ clashes. If the numbers are too small, we simply make them bigger!
{
if (ErrorNo <= Error->MinUserError) ErrorNo = Error->MinUserError;
Error->StoreErr(ErrorNo, Scanner->CurrSym);
}
int CRParser::In(unsigned short int *SymbolSet, int i)
{
return SymbolSet[i / NSETBITS] & (1 << (i % NSETBITS));
}
void CRParser::Expect(int n)
{
if (Sym == n) Get(); else GenError(n);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?