mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-08 13:11:54 +00:00
[script] add 2 new operators
- Str : Int -> works like py's [Int:] - Str - Int -> subtracts x amount of characters from the end of the string
This commit is contained in:
parent
95d4f2bbeb
commit
a39b3b2460
3 changed files with 33 additions and 1 deletions
|
@ -344,6 +344,36 @@ Variable_t solveEquation(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len, u8 sho
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (res.varType == StringType && val.varType == IntType){
|
||||
if (localOpToken == Minus){
|
||||
u32 resLen = strlen(res.stringType);
|
||||
if (resLen < val.integerType)
|
||||
return ErrValue(ERRSYNTAX);
|
||||
|
||||
char *temp = malloc(resLen - val.integerType + 1);
|
||||
memcpy(temp, res.stringType, resLen - val.integerType);
|
||||
temp[resLen - val.integerType] = 0;
|
||||
|
||||
freeVariable(res);
|
||||
res.stringType = temp;
|
||||
res.free = 1;
|
||||
}
|
||||
ELIFT(Selector){
|
||||
u32 resLen = strlen(res.stringType);
|
||||
if (resLen < val.integerType)
|
||||
return ErrValue(ERRSYNTAX);
|
||||
|
||||
char *temp = malloc(resLen - val.integerType + 1);
|
||||
memcpy(temp, res.stringType + val.integerType, resLen - val.integerType);
|
||||
temp[resLen - val.integerType] = 0;
|
||||
|
||||
freeVariable(res);
|
||||
res.stringType = temp;
|
||||
res.free = 1;
|
||||
}
|
||||
else
|
||||
return ErrValue(ERRBADOPERATOR);
|
||||
}
|
||||
else
|
||||
return ErrValue(ERRBADOPERATOR);
|
||||
}
|
||||
|
@ -351,7 +381,7 @@ Variable_t solveEquation(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len, u8 sho
|
|||
res = val;
|
||||
}
|
||||
}
|
||||
else if (tokens[i].token >= Plus && tokens[i].token <= OR) {
|
||||
else if (tokens[i].token >= Plus && tokens[i].token <= Selector) {
|
||||
lastToken = tokens[i].token;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ lexarTranslation_t lexarTranslations[] = {
|
|||
{'<', Smaller},
|
||||
{'>', Bigger},
|
||||
{'!', Not},
|
||||
{':', Selector},
|
||||
{')', RBracket},
|
||||
{']', RSBracket},
|
||||
{'(', LBracket},
|
||||
|
|
|
@ -37,6 +37,7 @@ enum Tokens {
|
|||
RSBracket,
|
||||
AND,
|
||||
OR,
|
||||
Selector,
|
||||
EquationSeperator,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue