string literals

There are 3 forms of string literals (6 if you count interpolated strings).

string literals
"string"
q"string"
Q"string"
...with interpolations
$"\.x;"
$q"\.x;"
$Q"\.x;"

String literals allow characters designated as "Graphic" by Unicode or from a Private Use Area.

The q and Q forms allow newlines within the quote. They also allow other quote marks to be used. Valid quote mark pairs are shown below.

The plain form and the q form for string literals interpret langur escape codes and the Q form does not.

Strings with interpolations are preceded by a $ token. Regex literals follow the same pattern for interpolations, such as $re/\.x;/.

q"" q'' q//
q() q[] q{} q<>

langur escape codes

\" \' \/ \) \] \} \> when otherwise used as a closing quote mark
\0 null (1 to 9 not defined)
\e escape
\t tab
\n line feed
\r carriage return
\N system newline
such as line feed or CR/LF
\L Unicode Line Separator
\P Unicode Paragraph Separator
\xXX 2 digit hexadecimal code unit (00 to 7F)
\oXXX 3 digit octal code unit (000 to 177)
\uXXXX 4 digit hexadecimal code point
\UXXXXXXXX 8 digit hexadecimal code point

Quote marks are not escaped by doubling, as I find that to be a confusing and inferior syntax.

string operators

~ (tilde) concatenate operator
x integer string x integer (see below)

string concatenation

The concatenation operator may be used between strings, or between a string and an integer (code point).

val .result = "A" ~ "B" # .result == "AB" val .result2 = "a" ~ 97 # .result2 == "ac"

string x integer

To repeat a string, use it with a multiplication operator and integer.

val .result = "A" x 4 # .result == "AAAA"

String multiplication, instead of throwing an exception, treats negative integers like 0.

string/regex literal interpolation

There are 5 forms of interpolation, all preceded by the \ escape character.

opening/closing marks and examples notes
. ;

$"\.var;"
$"\.x + .y;"
opening dot mark included as part of interpolated value
closes at first ; (no embededded semicolons)
{ }

$"\{.var}"
$"\{.x + .y}"
nested marks allowed
( )

$"\(.var)"
$"\(.x + .y)"
nested marks allowed
[ ]

$"\[.var]"
$"\[.x + .y]"
nested marks allowed (such as $"\[.x[1]]")
< >

$"\<.var>"
$"\<.x + .y>"
other nested marks allowed (not >)

Newlines are allowed within interpolated sections of strings that allow newlines, but never with the dot-semicolon form of interpolation.

code point literals

Code point literals are specified with straight single quotes.

They are integers. There is no code point type.

Escape codes may be used in code point literals, unless they might be more than a single code point (no system newline escape).

'a' code point literal for the lowercase a
'\uFEFF' code point literal for code point FEFF