langur

string literals

There are 3 forms of string literals (more if you count interpolated strings and block quotes).

without interpolation with interpolation
"string" $"\.x;"
q"string" $q"\.x;"
Q"string" $Q"\.x;"

The q and Q forms allow newlines within the quote.

quote marks

The q and Q forms allow other quote marks to be used. Valid quote mark pairs are shown below.

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

block quotes

Using a block modifier after a q or Q token, separated by a colon, allows you to use block quotes with a specific marker. This is similar to a "HEREDOC."

This may also be used with regex literals.

The ending marker must be on a line of its own, with no spacing around it.

val .str = q:block BLOCK_STRING some multi-line string ... BLOCK_STRING

The line return after the opening marker and the line return before the ending marker are not part of the string.

A block modifier is always the last modifier on a literal.

string/regex modifiers

String literals allow characters designated as "Graphic" by Unicode and ASCII space characters.

Regex literals have their own modifiers. Besides these, you can use an any modifier to allow any code point in a string or regex literal (as of 0.6.9).

q:any"..."

re:any"..."

langur escape codes

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

Bare octal escape codes are not allowed. Use \oXXX instead.

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

\" \' \/ \) \] \} \> 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

string miscellany

You can use a w// or W// literal for a quoted word array, as a semantic convenience.

Besides using empty quote marks, you can use the ZLS token for an empty string (zero-length string).

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 multiplication

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.

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 \N escape).

'a' lowercase a
'\L' Unicode line separator
'\uFEFF' code point FEFF; same as 16xFEFF

Bare code point literals (unescaped) allowed are the same as code points allowed in string literals.