-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsetools.cpp
More file actions
85 lines (73 loc) · 1.54 KB
/
parsetools.cpp
File metadata and controls
85 lines (73 loc) · 1.54 KB
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
#include "parsetools.h"
#include "tsymbol.h"
#include "tsyntobj.h"
void Tab( int level )
{
for( int i = 0 ; i < level ; ++i )
cout << '\t';
}
LoopInfo::LoopInfo()
:loops( 0 )
{}
void LoopInfo::LoopIn()
{
++loops;
}
void LoopInfo::LoopOut()
{
if ( loops )
--loops;
}
bool LoopInfo::IsInLoop()
{
return loops;
}
Operations::Operations()
{
Binary[0].push_back( oor );
Binary[1].push_back( oand );
Binary[2].push_back( oequal );
Binary[2].push_back( onequal );
Binary[3].push_back( ogreat );
Binary[3].push_back( oless );
Binary[3].push_back( oegreat );
Binary[3].push_back( oeless );
Binary[4].push_back( oplus );
Binary[4].push_back( ominus );
Binary[5].push_back( omul );
Binary[5].push_back( odiv );
Unary[0] = onot;
Unary[1] = oincr;
Unary[2] = odecr;
Unary[3] = oplus;
Unary[4] = ominus;
}
bool Operations::IsBinOnLev( Type type , int level )
{
level %= 6;
for ( int i = 0 ; i < Binary[level].size() ; ++i )
if ( type == Binary[level][i] )
return 1;
return 0;
}
bool Operations::IsUnary( Type type )
{
for ( int i = 0 ; i < 5 ; ++i )
if ( Unary[i] == type )
return 1;
return 0;
}
bool EqualArrays( TSymbol *a1 , TSymbol *a2 )
{
if ( !a1->IsArray() || !a2->IsArray() )
{
if ( a1->IsArray() || a2->IsArray() )
return 0;
if ( a1->GetRealType() != a2->GetRealType() )
return 0;
return 1;
}
if ( a1->GetSizeExpr()->GetInt() != a2->GetSizeExpr()->GetInt() )
return 0;
return EqualArrays( a1->type , a2->type );
}