From 1c8e4dba733f4feb9ef175007195283dfadfa23f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 10 Oct 2020 01:28:57 +0200 Subject: [PATCH] added \' escape character --- compiler/src/prog8/ast/antlr/Antr2Kotlin.kt | 1 + docs/source/syntaxreference.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/compiler/src/prog8/ast/antlr/Antr2Kotlin.kt b/compiler/src/prog8/ast/antlr/Antr2Kotlin.kt index 88c750cc5..36b728dcd 100644 --- a/compiler/src/prog8/ast/antlr/Antr2Kotlin.kt +++ b/compiler/src/prog8/ast/antlr/Antr2Kotlin.kt @@ -675,6 +675,7 @@ internal fun unescape(str: String, position: Position): String { 'n' -> '\n' 'r' -> '\r' '"' -> '"' + '\'' -> '\'' 'u' -> { "${iter.nextChar()}${iter.nextChar()}${iter.nextChar()}${iter.nextChar()}".toInt(16).toChar() } diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 68a48c220..88dc209a1 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -415,6 +415,7 @@ There are several escape sequences available to put special characters into your - ``\n`` - newline character (move cursor down and to beginning of next line) - ``\r`` - carriage return character (more or less the same as newline if printing to the screen) - ``\"`` - quote character (otherwise it would terminate the string) +- ``\'`` - apostrophe character (has to be escaped in character literals, is okay inside a string) - ``\uHHHH`` - a unicode codepoint \u0000 - \uffff (16-bit hexadecimal) - ``\xHH`` - 8-bit hex value that will be copied verbatim *without encoding*