Implemented compilation to SSA form
All checks were successful
/ test (push) Successful in 31s

This commit is contained in:
Eduard Urbach 2025-06-23 00:17:05 +02:00
parent f7be86a3d9
commit 31c5ed614c
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
27 changed files with 548 additions and 61 deletions

43
src/core/Unescape.go Normal file
View file

@ -0,0 +1,43 @@
package core
import "bytes"
// Unescape replaces the escape sequences in the contents of a string token with the respective characters.
func Unescape(data []byte) []byte {
data = data[1 : len(data)-1]
escape := bytes.IndexByte(data, '\\')
if escape == -1 {
return data
}
tmp := make([]byte, 0, len(data))
for {
tmp = append(tmp, data[:escape]...)
switch data[escape+1] {
case '0':
tmp = append(tmp, '\000')
case 't':
tmp = append(tmp, '\t')
case 'n':
tmp = append(tmp, '\n')
case 'r':
tmp = append(tmp, '\r')
case '"':
tmp = append(tmp, '"')
case '\'':
tmp = append(tmp, '\'')
case '\\':
tmp = append(tmp, '\\')
}
data = data[escape+2:]
escape = bytes.IndexByte(data, '\\')
if escape == -1 {
return tmp
}
}
}