string literals

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


The plain form and the q form for string literals interpret 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;/.

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

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)

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

string x integer

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

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

string/regex literal interpolation

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

opening/closing marks and examples notes
. ;

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

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

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

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

$"\<.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