[BUG] Disallow decimals on array decl and indices

[FEAT] Parser checks index out of bounds errors
This commit is contained in:
2021-05-04 16:29:37 +02:00
parent 28b059c57e
commit 7297215aeb
3 changed files with 11 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
#include "tokenizer.h"
#include "error.h"
#include <string>
static bool streq(const char* a, const char* b) {
while (*a != 0 && *b != 0) {
@@ -79,8 +80,8 @@ static void tkn_do_next() {
if (CCHR >= 48 && CCHR <= 57) {
do { value = value * 10 + (CCHR - 48); NEXT; } while (CCHR >= 48 && CCHR <= 57);
if (CCHR == '.') {
int d = 10;
do { value = value + ((CCHR - 48) / d); d *= 10; NEXT; } while (CCHR >= 48 && CCHR <= 57);
float d = 0.1f; NEXT;
do { value = value + (float(CCHR - 48) * d); d *= 0.1f; NEXT; } while (CCHR >= 48 && CCHR <= 57);
}
current_token = TOKEN_NUMBER; return;
}