Unicode literal to C like character literal
This commit is contained in:
@@ -399,6 +399,12 @@ lex__stream(Lexer *lexer){
|
||||
for(S32 i = 0; i < decode.advance; i++) lex_advance(s);
|
||||
t.unicode = decode.out_str;
|
||||
t.kind = TK_UnicodeLit;
|
||||
if(lexc(s) == '\''){
|
||||
lex_advance(s);
|
||||
}
|
||||
else{
|
||||
token_error(&t, "Unclosed unicode literal"_s);
|
||||
}
|
||||
}
|
||||
else{
|
||||
token_error(&t, "Invalid UTF8 sequence in unicode literal"_s);
|
||||
|
||||
@@ -24,7 +24,7 @@ main :: (): int
|
||||
assert(s64val == 0 && s32val == 0 && s16val == 0 && s8val == 0 && intval == 0 && u64val == 0 && u32val == 0 && u16val == 0 && u8val == 0 && f64val == 0 && f32val == 0)
|
||||
// @todo: Fix error here !!
|
||||
// assert(string_val[0] == 'S) //'
|
||||
assert(cstring_val[0] == 'C) //'
|
||||
assert(cstring_val[0] == 'C')
|
||||
|
||||
// This is how we can assign variables
|
||||
// There is no need for prefixes, compiler figures
|
||||
|
||||
@@ -46,24 +46,24 @@ main :: (): int
|
||||
assert(value_to_be_wrapped == 20)
|
||||
|
||||
letter := get_first_letter_of_type(value_to_be_wrapped)
|
||||
assert(letter == 'I) // '
|
||||
assert(letter == 'I')
|
||||
|
||||
get_first_letter_of_type :: (a: Any): U8
|
||||
type_info := get_type_info(a.type)
|
||||
if !type_info
|
||||
return '- // '
|
||||
return '-'
|
||||
|
||||
result: U8
|
||||
switch type_info.kind
|
||||
Type_Info_Kind.S64, Type_Info_Kind.S32, Type_Info_Kind.S16, Type_Info_Kind.S8, Type_Info_Kind.INT
|
||||
result = 'I // '
|
||||
result = 'I'
|
||||
Type_Info_Kind.U64, Type_Info_Kind.U32, Type_Info_Kind.U16, Type_Info_Kind.U8
|
||||
result = 'U // '
|
||||
result = 'U'
|
||||
Type_Info_Kind.F64
|
||||
result = 'F // '
|
||||
result = 'F'
|
||||
Type_Info_Kind.POINTER
|
||||
result = '* // '
|
||||
default;; result = '- // '
|
||||
result = '*'
|
||||
default;; result = '-'
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -142,11 +142,11 @@ test_unicode :: (arena: *Arena)
|
||||
string_result := string_to_string16(arena, string)
|
||||
print(string_result)
|
||||
|
||||
s32, s32_len := utf8_to_utf32(&"A"[0], 1)
|
||||
assert(s32 == 'A, "Invalid decode") // '
|
||||
s32, s32_len := utf8_to_utf32('A', 1)
|
||||
assert(s32 == 'A', "Invalid decode")
|
||||
|
||||
s32_2, s32_len_2 := utf8_to_utf32(&"ć"[0], 2)
|
||||
s32_2, s32_len_2 := utf8_to_utf32('ć', 2)
|
||||
assert(s32_2 == 0x107, "Invalid decode")
|
||||
|
||||
s32_3, s32_len_3 := utf8_to_utf32(&"ó"[0], 2)
|
||||
s32_3, s32_len_3 := utf8_to_utf32('ó', 2)
|
||||
assert(s32_3 == 0xF3, "Invalid decode")
|
||||
|
||||
@@ -85,7 +85,7 @@ itoa :: (value: S64, result: *U8, base: S64): *U8
|
||||
|
||||
// Apply negative sign
|
||||
if tmp_value < 0
|
||||
*ptr++ = '- // '
|
||||
*ptr++ = '-'
|
||||
*ptr-- = 0
|
||||
for ptr1 < ptr
|
||||
tmp_char = *ptr
|
||||
@@ -100,7 +100,7 @@ print :: (string: String, args: ..)
|
||||
|
||||
arg_counter := 0
|
||||
for i := 0, i < length_of(string), i+=1
|
||||
if string[i] == '% // '
|
||||
if string[i] == '%'
|
||||
assert(arg_counter < length_of(args), "Passing too many [%] to a print lambda")
|
||||
arg := args[arg_counter++]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user