X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibspiderscript.so_src%2Flex.c;h=fd395e0f2d188f07a65473ceaea20184630c7555;hb=270e5fe88b0666021a7a6393334db7feeb8245f8;hp=25a7aa7ec3a08dd50f65e4681d6e89b70042aadc;hpb=1529dadb6c2170bf9899fbde46d06a3d9a392b52;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libspiderscript.so_src/lex.c b/Usermode/Libraries/libspiderscript.so_src/lex.c index 25a7aa7e..fd395e0f 100644 --- a/Usermode/Libraries/libspiderscript.so_src/lex.c +++ b/Usermode/Libraries/libspiderscript.so_src/lex.c @@ -7,6 +7,8 @@ #include #include +// Make the scope character ('.') be a symbol, otherwise it's just +// a ident character #define USE_SCOPE_CHAR 0 #define DEBUG 0 @@ -25,9 +27,19 @@ const struct { const char *Name; } csaReservedWords[] = { {TOK_RWD_FUNCTION, "function"}, + {TOK_RWD_RETURN, "return"}, + {TOK_RWD_NEW, "new"}, + + {TOK_RWD_IF, "if"}, + {TOK_RWD_ELSE, "else"}, + {TOK_RWD_DO, "do"}, + {TOK_RWD_WHILE, "while"}, + {TOK_RWD_FOR, "for"}, + {TOK_RWD_VOID, "void"}, {TOK_RWD_OBJECT, "Object"}, + {TOK_RWD_OPAQUE, "Opaque"}, {TOK_RWD_INTEGER, "Integer"}, {TOK_RWD_REAL, "Real"}, {TOK_RWD_STRING, "String"} @@ -124,6 +136,33 @@ int GetToken(tParser *File) 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; @@ -190,11 +229,23 @@ int GetToken(tParser *File) // 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; }