more on strings

This commit is contained in:
anon 2024-07-17 00:04:29 +02:00
parent 2762655144
commit 7222328ace
2 changed files with 24 additions and 0 deletions

View File

@ -236,6 +236,7 @@ library { BEGIN INITIAL; return END_LIBRARY; }
\\r { string_literal_buffer_append_char('\r'); }
\\t { string_literal_buffer_append_char('\t'); }
\\v { string_literal_buffer_append_char('\v'); }
\\0 { string_literal_buffer_append_char('\0'); }
\\\" { string_literal_buffer_append_char('\"'); }
\\\\ { string_literal_buffer_append_char('\\'); }
\\x({hex}|{uhex})+ {
@ -244,6 +245,13 @@ library { BEGIN INITIAL; return END_LIBRARY; }
memcpy(string_literal_buffer + string_litral_buffer_size, &v, sizeof(long));
string_litral_buffer_size += sizeof(long);
}
\n {
issue_error("string was never terminated");
yylval.blobval.data = strdup("");
yylval.blobval.len = 0;
string_litral_buffer_size = 0;
return ARRAY_LITERAL;
}
. { string_literal_buffer_append_char(yytext[0]); }
}

View File

@ -92,6 +92,20 @@ class CMDTEST_error_batch < Cmdtest::Testcase
end
end
def test_cut_string
create_file "input.eax", <<-HEREDOC
program main
u8 <> kek = "asd
begin
end program
HEREDOC
cmd "eaxhla input.eax" do
stderr_equal /.+\n(.|\n)+/m
exit_status 1
end
end
def test_multi_error
create_file "input.eax", <<-HEREDOC
program main
@ -128,6 +142,7 @@ class CMDTEST_warning_batch < Cmdtest::Testcase
ignore_file $default_output_file
cmd "eaxhla input.eax" do
created_files "a.out"
stderr_equal /.+/
end
end
@ -139,6 +154,7 @@ class CMDTEST_warning_batch < Cmdtest::Testcase
ignore_file $default_output_file
cmd "eaxhla input.eax" do
created_files "a.out"
stderr_equal /.+/
end
end