case '\0': ret = TOK_EOF; break;
// Operations
+ case '^':
+ if( *File->CurPos == '^' ) {
+ File->CurPos ++;
+ ret = TOK_LOGICXOR;
+ break;
+ }
+ ret = TOK_XOR;
+ break;
+
+ case '|':
+ if( *File->CurPos == '|' ) {
+ File->CurPos ++;
+ ret = TOK_LOGICOR;
+ break;
+ }
+ ret = TOK_OR;
+ break;
+
+ case '&':
+ if( *File->CurPos == '&' ) {
+ File->CurPos ++;
+ ret = TOK_LOGICAND;
+ break;
+ }
+ ret = TOK_AND;
+ break;
+
case '/': ret = TOK_DIV; break;
case '*': ret = TOK_MUL; break;
case '+': ret = TOK_PLUS; break;
// Default (Numbers and Identifiers)
default:
File->CurPos --;
+
// Numbers
if( isdigit(*File->CurPos) )
{
- while( isdigit(*File->CurPos) )
- File->CurPos ++;
+ if( *File->CurPos == '0' && File->CurPos[1] == 'x' ) {
+ File->CurPos += 2;
+ while(('0' <= *File->CurPos && *File->CurPos <= '9')
+ || ('A' <= *File->CurPos && *File->CurPos <= 'F')
+ || ('a' <= *File->CurPos && *File->CurPos <= 'f') )
+ {
+ File->CurPos ++;
+ }
+ }
+ else {
+ while( isdigit(*File->CurPos) )
+ File->CurPos ++;
+ }
ret = TOK_INTEGER;
break;
}
*/
tAST_Node *Parse_GetNumeric(tParser *Parser)
{
- uint64_t value;
+ uint64_t value = 0;
+ char *pos;
GetToken( Parser );
- value = atoi( Parser->TokenStr );
+ pos = Parser->TokenStr;
+ //printf("pos = %p, *pos = %c\n", pos, *pos);
+
+ if( *pos == '0' )
+ {
+ pos ++;
+ if(*pos == 'x') {
+ pos ++;
+ for( ;; pos++)
+ {
+ value *= 16;
+ if( '0' <= *pos && *pos <= '9' ) {
+ value += *pos - '0';
+ continue;
+ }
+ if( 'A' <= *pos && *pos <= 'F' ) {
+ value += *pos - 'A' + 10;
+ continue;
+ }
+ if( 'a' <= *pos && *pos <= 'f' ) {
+ value += *pos - 'a' + 10;
+ continue;
+ }
+ break;
+ }
+ }
+ else {
+ while( '0' <= *pos && *pos <= '7' ) {
+ value = value*8 + *pos - '0';
+ pos ++;
+ }
+ }
+ }
+ else {
+ while( '0' <= *pos && *pos <= '9' ) {
+ value = value*10 + *pos - '0';
+ pos ++;
+ }
+ }
+
return AST_NewInteger( Parser, value );
}