-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecgValIntro.cpp
52 lines (51 loc) · 1.09 KB
/
recgValIntro.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "syntaxAnalys.h"
#include <iostream>
#include "getSym.h"
#include "error.h"
using namespace std;
int recgValIntro(int level) {
int curState = 0;
streampos sp = sourceFile.tellg();
int n = curSym.len;
int type = curSym.getType();
try {
if (curSym.getType() != CONST_SYM) {
throw(E_NOT_THIS);
}
getSym();
recgValDef(level);
if (curSym.getType() != SEMICOL_SYM) {
reportError(E_MISS_TOKEN);
char until[2] = { ';','\n' };
skip(until, 2);
curState = E_MISS_TOKEN;
}
sp = sourceFile.tellg();
while (true) {
getSym();
if (curSym.getType() != CONST_SYM)
break;
getSym();
recgValDef(level);
if (curSym.getType() != SEMICOL_SYM) {
reportError(E_MISS_TOKEN);
char until[2] = { ';','\n' };
skip(until, 2);
curState = E_MISS_TOKEN;
}
sp = sourceFile.tellg();
}
seekSp(sp);
curChar = sourceFile.get();
cout << "At line " << lineNum << " This is a const declaration statement!" << endl;
getSym();
return 0;
}
catch (int) {
seekSp(sp);
backSym(n, type);
curChar = sourceFile.get();
getSym();
return -E_NOT_THIS;
}
}