static int _Alextab(compileContext *ctx, int __na__) { // fucko: JF> 17 -> 19? if (__na__ >= 0 && __na__ <= 17) { ctx->colCount+=nseel_gettokenlen(ctx,256); } switch (__na__) { case 0: { char tmp[NSEEL_MAX_VARIABLE_NAMELEN*2]; nseel_gettoken(ctx,tmp, sizeof(tmp)); if (tmp[0] < '0' || tmp[0] > '9') // not sure where this logic came from { ctx->yylval = nseel_lookup(ctx,&__na__,tmp); return __na__; } } case 1: case 2: case 3: { char tmp[NSEEL_MAX_VARIABLE_NAMELEN*2]; nseel_gettoken(ctx,tmp, sizeof(tmp)); ctx->yylval = nseel_translate(ctx,tmp); return VALUE; } case 4: case 5: { char tmp[NSEEL_MAX_VARIABLE_NAMELEN*2]; nseel_gettoken(ctx,tmp, sizeof(tmp)); ctx->yylval = nseel_lookup(ctx,&__na__,tmp); return __na__; } case 6: return '+'; case 7: return '-'; case 8: return '*'; case 9: return '/'; case 10: return '%'; case 11: return '&'; case 12: return '|'; case 13: return '('; case 14: return ')'; case 15: return '='; case 16: return ','; case 17: return ';'; } return (LEXSKIP); }
//------------------------------------------------------------------------------ INT_PTR nseel_translate(compileContext *ctx, int type) { int v; int n; *ctx->yytext = 0; nseel_gettoken(ctx,ctx->yytext, sizeof(ctx->yytext)); switch (type) { case INTCONST: return nseel_createCompiledValue(ctx,(EEL_F)atoi(ctx->yytext), NULL); case DBLCONST: return nseel_createCompiledValue(ctx,(EEL_F)atof(ctx->yytext), NULL); case HEXCONST: v=0; n=0; while (1) { int a=ctx->yytext[n++]; if (a >= '0' && a <= '9') v=(v<<4)+a-'0'; else if (a >= 'A' && a <= 'F') v=(v<<4)+10+a-'A'; else if (a >= 'a' && a <= 'f') v=(v<<4)+10+a-'a'; else break; } return nseel_createCompiledValue(ctx,(EEL_F)v, NULL); } return 0; }
//------------------------------------------------------------------------------ void nseel_setLastVar(compileContext *ctx) { nseel_gettoken(ctx,ctx->lastVar, sizeof(ctx->lastVar)); }
//--------------------------------------------------------------------------- void nseel_count(compileContext *ctx) { nseel_gettoken(ctx,ctx->yytext, sizeof(ctx->yytext)); ctx->colCount+=strlen(ctx->yytext); }
//------------------------------------------------------------------------------ INT_PTR nseel_lookup(compileContext *ctx, int *typeOfObject) { int i, ti, wb; const char *nptr; nseel_gettoken(ctx,ctx->yytext, sizeof(ctx->yytext)); if (!strnicmp(ctx->yytext,"reg",3) && strlen(ctx->yytext) == 5 && isdigit(ctx->yytext[3]) && isdigit(ctx->yytext[4]) && (i=atoi(ctx->yytext+3))>=0 && i<100) { *typeOfObject=IDENTIFIER; return i+NSEEL_GLOBALVAR_BASE; } i=0; for (wb = 0; wb < ctx->varTable_numBlocks; wb ++) { int namepos=0; for (ti = 0; ti < NSEEL_VARS_PER_BLOCK; ti ++) { if (!ctx->varTable_Names[wb][namepos]) break; if (!strnicmp(ctx->varTable_Names[wb]+namepos,ctx->yytext,NSEEL_MAX_VARIABLE_NAMELEN)) { *typeOfObject = IDENTIFIER; return i; } namepos += NSEEL_MAX_VARIABLE_NAMELEN; i++; } if (ti < NSEEL_VARS_PER_BLOCK) break; } nptr = ctx->yytext; if (!strcasecmp(nptr,"if")) nptr="_if"; else if (!strcasecmp(nptr,"bnot")) nptr="_not"; else if (!strcasecmp(nptr,"assign")) nptr="_set"; else if (!strcasecmp(nptr,"equal")) nptr="_equal"; else if (!strcasecmp(nptr,"below")) nptr="_below"; else if (!strcasecmp(nptr,"above")) nptr="_above"; else if (!strcasecmp(nptr,"megabuf")) nptr="_mem"; else if (!strcasecmp(nptr,"gmegabuf")) nptr="_gmem"; else if (!strcasecmp(nptr,"int")) nptr="floor"; for (i=0;nseel_getFunctionFromTable(i);i++) { functionType *f=nseel_getFunctionFromTable(i); if (!strcasecmp(f->name, nptr)) { switch (f->nParams) { case 1: *typeOfObject = FUNCTION1; break; case 2: *typeOfObject = FUNCTION2; break; case 3: *typeOfObject = FUNCTION3; break; default: *typeOfObject = IDENTIFIER; break; } return i; } } *typeOfObject = IDENTIFIER; nseel_setLastVar(ctx); return nseel_setVar(ctx,-1); }