From 18847f55bb3fe9db41e46a2e9e49a9f7c28143af Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 10 Feb 2020 14:45:20 +0100 Subject: pkg/ast: introduce hex-encoded string literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stringnozescapes does not make sense with filename, also we may need similar escaping for string flags. Handle escaped strings on ast level instead. This avoids introducing new type and works seamleassly with flags. As alternative I've also tried using strconv.Quote/Unquote but it leads to ugly half-escaped strings: "\xb0\x80s\xe8\xd4N\x91\xe3ڒ,\"C\x82D\xbb\x88\\i\xe2i\xc8\xe9\xd85\xb1\x14):M\xdcn" Make hex-encoded strings a separate string format instead. --- pkg/ast/testdata/all.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'pkg/ast/testdata') diff --git a/pkg/ast/testdata/all.txt b/pkg/ast/testdata/all.txt index 392796254..122fa514b 100644 --- a/pkg/ast/testdata/all.txt +++ b/pkg/ast/testdata/all.txt @@ -17,15 +17,14 @@ int_flags4 = 1, -2- ### bad integer "-2-" str_flags0 = "foo", "bar" str_flags1 = "non terminated ### string literal is not terminated str_flags2 = "bad chars здесь" ### illegal character U+00D0 'Ð' in string literal -str_flags3 = "string", not a string ### unexpected identifier, expecting string -str_flags4 = "string", 42 ### unexpected int, expecting string +str_flags3 = "string", not a string ### unexpected identifier, expecting string, hex string +str_flags4 = "string", 42 ### unexpected int, expecting string, hex string call(foo ,int32 , bar int32) ### unexpected ',', expecting int, identifier, string call(foo int32:"bar") ### unexpected string, expecting int, identifier call(a int32, b len[a:"bar"]) ### unexpected string, expecting int, identifier -define FOO `bar` -define FOO `bar ### C expression is not terminated +define FOO bar foo(x int32[1:2:3, opt]) foo2(x int32[1[2]:2]) ### unexpected ':', expecting ']' -- cgit mrf-deployment