-
Notifications
You must be signed in to change notification settings - Fork 0
/
Variable.cpp
101 lines (82 loc) · 1.68 KB
/
Variable.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "Variable.h"
char a[]={'@'};
//int a[]={-17};
const vector<int> Variable::EliminationVariable(a,a+1);
// Begin input output
/*
bool Variable::readStream(istream &in) {
char c;
if( !in.get( c ) )
{
if(tuple.empty())
tuple.push_back(c);
else tuple[0] = c;
return false;
}
if(tuple.empty())
tuple.push_back(c);
else tuple[0] = c;
if ( ( c < 'a' || 'z' < c ) && ( c < 'A' || 'Z' < c ) ) {
in.unget();
return false;
}
int n;
in.get( c );
if ( c== '[' ) {
if ( !(in >> n) ) return false;
tuple.push_back(n);
}
else{
in.unget();
return true;
}
in.get( c );//"]"
in.get( c );
if ( c== '[' ) {
if ( !(in >> n) ) return false;
tuple.push_back(n);
}
else in.unget();
return true;
}*/
bool Variable::readStream(istream &in) {
tuple.clear();
char c;
if( !in.get( c ) )
{
if(tuple.empty())
tuple.push_back(c);
else tuple[0] = c;
return false;
}
if(tuple.empty())
tuple.push_back(c);
else tuple[0] = c;
if ( ( c < 'a' || 'z' < c ) && ( c < 'A' || 'Z' < c ) ) {
in.unget();
return false;
}
int n;
in.get( c );
if ( c== '_' ) {
if ( !(in >> n) ) return false;
if(tuple.size()==1)
tuple.push_back(n);
else
tuple[1] = n;
return true;
}
else{
in.unget();
return true;
}
/*
in.get( c );
if ( c== '_' ) {
if ( !(in >> n) ) return false;
tuple.push_back(n);
}
else in.unget();
*/
return true;
}