More variable stuff
This commit is contained in:
+21
@@ -44,6 +44,8 @@ static const KeywordMap keywords[] = {
|
||||
{"u16", TOKEN_U16},
|
||||
{"u32", TOKEN_U32},
|
||||
{"u64", TOKEN_U64},
|
||||
{"true", TOKEN_TRUE},
|
||||
{"false", TOKEN_FALSE},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -234,8 +236,27 @@ Token tokenstream_next(TokenStream* ts) {
|
||||
case ',': return create_token(ts, TOKEN_COMMA, start_text, 1, start_line, start_column, line_start);
|
||||
case ';': return create_token(ts, TOKEN_SEMICOLON, start_text, 1, start_line, start_column, line_start);
|
||||
case '=': return create_token(ts, TOKEN_ASSIGN, start_text, 1, start_line, start_column, line_start);
|
||||
case '"': {
|
||||
size_t len = 0;
|
||||
const char* start = &ts->code[ts->pos];
|
||||
while (peek_char(ts) != '"' && peek_char(ts) != '\0') {
|
||||
read_char(ts);
|
||||
len++;
|
||||
}
|
||||
if (peek_char(ts) == '"') read_char(ts);
|
||||
return create_token(ts, TOKEN_STRING, start, len, start_line, start_column + 1, line_start);
|
||||
}
|
||||
}
|
||||
|
||||
if (isdigit(c)) {
|
||||
size_t len = 1;
|
||||
while (isdigit(peek_char(ts))) {
|
||||
read_char(ts);
|
||||
len++;
|
||||
}
|
||||
return create_token(ts, TOKEN_INTEGER, start_text, len, start_line, start_column, line_start);
|
||||
}
|
||||
|
||||
/* Keywords and identifiers */
|
||||
if (is_identifier_start(c)) {
|
||||
/* Declarations first for C89 */
|
||||
|
||||
Reference in New Issue
Block a user