From c4f3b1c105f3b1d79bc47051bea072ec8ab99f75 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Sun, 30 Jun 2024 23:35:57 +0800 Subject: [PATCH] Language Construct docs for string operators and string escape sequences. --- site/constructs.pug | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/site/constructs.pug b/site/constructs.pug index b68ab1e..48c39a2 100644 --- a/site/constructs.pug +++ b/site/constructs.pug @@ -484,6 +484,65 @@ html(lang="en") | handle error { | render "Error: " + error + "\r\n"; | }; + br + + h5(class="border-bottom pb-2 fw-bold") Strings + p In Uartix, strings are sequences of characters enclosed in double quotes ("). Strings are used to represent text and can contain a variety of characters, including letters, numbers, punctuation, and special characters. + p Additionally, strings can be concatenated using the + operator and can also be reversed with the ~ unary operator. The multiplication (*) operator can also multiply a string. + + div(class="bg-primary w-100 mt-2") + p(class="text-white m-0 ms-2") example_26.utx + code(class="text-dark") + pre(class="border border-primary p-2") + | # String operation example. + | + | render (~"Hello") + "\r\n"; + | render "Go! " * 3; + br + + b(class="pb-2") Escape Sequences + p Escape sequences are used in strings to represent special characters that cannot be directly included in the string. An escape sequence begins with a backslash (\) followed by one or more characters. Uartix supports several escape sequences: + + ul + li + b Newline (\n) + p Represents a newline character, which moves the cursor to the beginning of the next line. + li + b Carriage Return (\r) + p Represents a carriage return character, which moves the cursor to the beginning of the current line. + li + b Tab (\t) + p Represents a tab character, which moves the cursor to the next tab stop. + li + b Backspace (\b) + p Represents a backspace character, which moves the cursor one position to the left. + li + b Form Feed (\f) + p Represents a form feed character, which moves the cursor to the beginning of the next page. + li + b Double Quote (\") + p Represents a double quote character, allowing double quotes to be included within strings. + li + b Backslash (\\) + p Represents a backslash character, allowing backslashes to be included within strings. + li + b Unicode (\uXXXX) + p Represents a Unicode character, where XXXX is a four-digit hexadecimal number corresponding to the Unicode code point. + + div(class="bg-primary w-100 mt-2") + p(class="text-white m-0 ms-2") example_27.utx + code(class="text-dark") + pre(class="border border-primary p-2") + | # String escape sequence examples. + | + | render "Hello,\nWorld!\r\n"; + | render "Hello,\rWorld!\r\n"; + | render "Hello,\tWorld!\r\n"; + | render "Hello,\bWorld!\r\n"; + | render "Hello,\fWorld!\r\n"; + | render "They say, \"Hello, World!\"\r\n"; + | render "This is a backslash: \\\r\n"; + | render "Smiley face: \u263A\r\n"; div(class="col-lg-2")