From 4f0f48678b0f6f1e845ba57e85ef0cc4d5ec982c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 13 Jun 2024 12:40:40 +0200 Subject: [PATCH 1/3] Specify syntactic restrictions on let else initializers --- src/statements.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/statements.rst b/src/statements.rst index 0b500d58..5b4f03b5 100644 --- a/src/statements.rst +++ b/src/statements.rst @@ -75,6 +75,11 @@ alternatively executes a :t:`block expression`. If a :t:`let statement` lacks a :t:`block expression`, then the :t:`pattern` of the :t:`let statement` shall be an :t:`irrefutable pattern`. +:dp:`fls_1s1UikGU5YQb` +If a :t:`let statement` has a :t:`block expression`, then the :s:`Expression` of +the :s:`LetInitializer` shall not be a :s:`LazyBooleanExpression` or end with +token ``}``. + :dp:`fls_iB25BeFys0j8` The :t:`expected type` of the :t:`pattern` of the :t:`let statement` is determined as follows: From 479ae21d8fb5d011d66b1afa1067c109ceac2859 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 13 Jun 2024 13:21:03 +0200 Subject: [PATCH 2/3] Add c string literals --- src/glossary.rst | 37 +++++++++++++ src/lexical-elements.rst | 113 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 149 insertions(+), 1 deletion(-) diff --git a/src/glossary.rst b/src/glossary.rst index 02f85914..3662b08e 100644 --- a/src/glossary.rst +++ b/src/glossary.rst @@ -1026,6 +1026,18 @@ C signed int type :dp:`fls_8QIcvapJehqY` :dt:`C signed int type` is the `signed int` :t:`type` of the :t:`C` language. +.. _fls_roz4WXH5JZFj: + +c string literal +^^^^^^^^^^^^^^^^ + +:dp:`fls_g3NHtaOhTB7g` +A :dt:`c string literal` is a :t:`literal` that consists of multiple characters +with an implicit 0x00 byte appended to it. + +:dp:`fls_FZ6QSpjmVme5` +See :s:`CStringLiteral`. + .. _fls_Egfa8tdbqllA: Call conformance @@ -5279,6 +5291,18 @@ not recognize :t:`[escaped character]s`. :dp:`fls_5x71i3ay3na2` See ``RawByteStringLiteral.`` +.. _fls_yGGvg3e0nPOh: + +raw c string literal +^^^^^^^^^^^^^^^^^^^^ + +:dp:`fls_qhWBzqoYZL0e` +A :dt:`raw c string literal` is a :t:`simple c string literal` that does not +recognize :t:`[escaped character]s`. + +:dp:`fls_WpFJyq6q4k6E` +See ``RawCStringLiteral.`` + .. _fls_uv4dyt4gi32x: raw pointer @@ -6015,6 +6039,19 @@ of multiple :s:`[AsciiCharacter]s`. :dp:`fls_OfI70zK68TnQ` See :s:`SimpleByteStringLiteral`. +.. _fls_fx2hhB0HHSUG: + +simple c string literal +^^^^^^^^^^^^^^^^^^^^^^^ + +:dp:`fls_qoHXrmds9SgI` +A :dt:`simple c string literal` is any :t:`Unicode` character except characters +0x0D (carriage return), 0x22 (quotation mark), 0x5C (reverse solidus) and 0x00 +(null byte). + +:dp:`fls_ggm5FNUqg9EY` +See :s:`SimpleCStringLiteral`. + .. _fls_6mcm7xdcyn40: simple import diff --git a/src/lexical-elements.rst b/src/lexical-elements.rst index 646c4d6e..0c83eeab 100644 --- a/src/lexical-elements.rst +++ b/src/lexical-elements.rst @@ -547,6 +547,7 @@ Literals BooleanLiteral | ByteLiteral | ByteStringLiteral + | CStringLiteral | CharacterLiteral | NumericLiteral | StringLiteral @@ -703,6 +704,116 @@ The :t:`type` of a :t:`raw byte string literal` of size ``N`` is ``&'static br#""# br##"left #"# right"## +.. _fls_U1gHCy16emVe: + +C String Literals +~~~~~~~~~~~~~~~~~ + +.. rubric:: Syntax + +.. syntax:: + CStringLiteral ::= + RawCStringLiteral + | SimpleCStringLiteral + +.. rubric:: Legality Rules + +:dp:`fls_VKCW830CzhhN` +A :t:`c string literal` is a :t:`literal` that consists of multiple characters +with an implicit 0x00 byte appended to it. + +:dp:`fls_XJprzaEn82Xs` +The character sequence 0x0D 0xCA (carriage return, new line) is replaced by 0xCA +(new line) inside of a :t:`c string literal`. + +.. _fls_p090c5oTnElW: + +Simple C String Literals +^^^^^^^^^^^^^^^^^^^^^^^^ + +.. rubric:: Syntax + +.. syntax:: + + SimpleCStringLiteral ::= + $$c"$$ SimpleCStringContent* $$"$$ + + SimpleCStringContent ::= + AsciiEscape + | SimpleStringCharacter + | StringContinuation + | UnicodeEscape + +:dp:`fls_fnwQHo7twAom` +A :t:`simple c string literal` is any :t:`Unicode` character except characters +0x0D (carriage return), 0x22 (quotation mark), 0x5C (reverse solidus) and 0x00 +(null byte). + +:dp:`fls_hp1DTpqDwuLC` +:ds:`StringContinuation` is the character sequence 0x5C 0x0A (reverse solidus, +new line). + +.. rubric:: Legality Rules + +:dp:`fls_nPI7j0siGP8G` +A :t:`simple c string literal` is a :t:`c string literal` where the characters are +:t:`Unicode` characters. + +:dp:`fls_Ae7LM4Wg0NA7` +The :t:`type` of a :t:`simple string literal` is :std:`&'static +[core::ffi::CStr]`. + +.. rubric:: Examples + +.. code-block:: rust + + c"" + c"cat" + c"\tcol\nrow" + c"bell\x07" + c"\u{B80a}" + c"\ + multi\ + line\ + string" + +.. _fls_G4LdypF3rL6i: + +Raw C String Literals +^^^^^^^^^^^^^^^^^^^^^ + +.. rubric:: Syntax + +.. syntax:: + + RawCStringLiteral ::= + $$cr$$ RawCStringContent + + RawCStringContent ::= + NestedRawCStringContent + | $$"$$ ~[$$\r$$]* $$"$$ + + NestedRawCStringContent ::= + $$#$$ RawCStringContent $$#$$ + +.. rubric:: Legality Rules + +:dp:`fls_gLrei65i8Uzq` +A :t:`raw c string literal` is a :t:`simple c string literal` that does not +recognize :t:`[escaped character]s`. + +:dp:`fls_9nJHsg9dCi66` +The :t:`type` of a :t:`simple string literal` is :std:`&'static +[core::ffi::CStr]`. + +.. rubric:: Examples + +.. code-block:: rust + + cr"" + cr#""# + cr##"left #"# right"## + .. _fls_hv9jtycp0o1y: Numeric Literals @@ -1097,7 +1208,7 @@ The :t:`type` of a :t:`simple string literal` is ``&'static str``. "cat" "\tcol\nrow" "bell\x07" - "\uB80a" + "\u{B80a}" "\ multi\ line\ From 3d21066df024d02621415cf5b8c608f4bfcb17e8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 13 Jun 2024 15:15:50 +0200 Subject: [PATCH 3/3] Remove duplicate definition of StringContinuation --- src/lexical-elements.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lexical-elements.rst b/src/lexical-elements.rst index 0c83eeab..abc4ab2f 100644 --- a/src/lexical-elements.rst +++ b/src/lexical-elements.rst @@ -749,10 +749,6 @@ A :t:`simple c string literal` is any :t:`Unicode` character except characters 0x0D (carriage return), 0x22 (quotation mark), 0x5C (reverse solidus) and 0x00 (null byte). -:dp:`fls_hp1DTpqDwuLC` -:ds:`StringContinuation` is the character sequence 0x5C 0x0A (reverse solidus, -new line). - .. rubric:: Legality Rules :dp:`fls_nPI7j0siGP8G`