-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.cpp
44 lines (42 loc) · 1.6 KB
/
misc.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
#include "misc.hpp"
bool g_HadError = false;
int g_NumErrors = 0;
//-------------------------------------------------------------------------------------------------
void error ( std::string message,
int line,
int offset )
{
std::cerr << "[offset: "<< offset << ",line: "<< line << "] Error" << ": " << message << std::endl;
g_HadError = true;
++ g_NumErrors;
}
//-------------------------------------------------------------------------------------------------
int decaDigit ( char asses )
{
if ( asses >= '0' && asses <= '9' )
return asses - '0';
else
return -1;
}
//-------------------------------------------------------------------------------------------------
int octaDigit ( char asses )
{
if ( asses >= '0' && asses <= '7' )
return asses - '0';
else
return -1;
}
//-------------------------------------------------------------------------------------------------
int hexaDigit ( char asses )
{
if ( ( asses >= '0' && asses <= '9' ) || ( asses >= 'A' && asses <= 'F' ) )
{
if ( asses >= '0' && asses <= '9' )
return asses - '0';
else
return asses - 'A' + 10;
}
else
return -1;
}
//-------------------------------------------------------------------------------------------------