hex and oct number can be recognized
This commit is contained in:
parent
01bfda8f5e
commit
09685f4223
|
@ -40,6 +40,16 @@ bool isNumber(char t)
|
||||||
return (('0'<=t) && (t<='9'));
|
return (('0'<=t) && (t<='9'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isHex(char t)
|
||||||
|
{
|
||||||
|
return ((('0'<=t) && (t<='9')) || (('a'<=t) && (t<='f')));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isOct(char t)
|
||||||
|
{
|
||||||
|
return (('0'<=t) && (t<='7'));
|
||||||
|
}
|
||||||
|
|
||||||
class resource_programme_process
|
class resource_programme_process
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -160,6 +170,34 @@ class nasal_lexer
|
||||||
syn=RESERVEWORD;
|
syn=RESERVEWORD;
|
||||||
}
|
}
|
||||||
else if(isNumber(temp))
|
else if(isNumber(temp))
|
||||||
|
{
|
||||||
|
if((source[ptr]=='0') && (source[ptr+1]=='x'))
|
||||||
|
{
|
||||||
|
__token+=source[ptr];
|
||||||
|
__token+=source[ptr+1];
|
||||||
|
ptr+=2;
|
||||||
|
temp=source[ptr];
|
||||||
|
while(isNumber(temp) || isHex(temp))
|
||||||
|
{
|
||||||
|
__token+=temp;
|
||||||
|
++ptr;
|
||||||
|
temp=source[ptr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((source[ptr]=='0') && (source[ptr+1]=='o'))
|
||||||
|
{
|
||||||
|
__token+=source[ptr];
|
||||||
|
__token+=source[ptr+1];
|
||||||
|
ptr+=2;
|
||||||
|
temp=source[ptr];
|
||||||
|
while(isNumber(temp) || isOct(temp))
|
||||||
|
{
|
||||||
|
__token+=temp;
|
||||||
|
++ptr;
|
||||||
|
temp=source[ptr];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int PointCnt=0;
|
int PointCnt=0;
|
||||||
while(isNumber(temp))
|
while(isNumber(temp))
|
||||||
|
@ -175,6 +213,7 @@ class nasal_lexer
|
||||||
temp=source[ptr];
|
temp=source[ptr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
syn=NUMBER;
|
syn=NUMBER;
|
||||||
}
|
}
|
||||||
else if(temp=='(' || temp==')' || temp=='[' || temp==']' || temp=='{' ||
|
else if(temp=='(' || temp==')' || temp=='[' || temp==']' || temp=='{' ||
|
||||||
|
|
Loading…
Reference in New Issue