Skip to content

Commit db4f66c

Browse files
authored
Update remove_phase_2.md
1 parent e317d99 commit db4f66c

File tree

1 file changed

+30
-41
lines changed

1 file changed

+30
-41
lines changed

docs/remove_phase_2.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
1-
## Removing Phase 2
1+
2+
## Removal of Phase 2
23

34
### Motivation
45

5-
Phase 2, works as being a preprocessor of the preprocessor, it does not make any distinction or judgment
6-
about where the backslash character `\` followed by a newline can be used. This allows it to be used in
7-
nonsensical places like in the middle of identifiers, punctuations and `//single-line comment`.
8-
I propose we remove Phase 2 and handle the backslash character `\` followed by a newline in Phase 3.
6+
Phase 2 works as a preprocessor of the preprocessor, without making any distinction or judgment about where the backslash character `\` followed by a newline can be used. This allows it to appear in nonsensical places such as in the middle of keywords, identifiers, constants, punctuation, and at the end of single-line comments.
97

10-
## Current Text of Phase 2
8+
This complexity makes the language and tools more cumbersome and can create errors due to the misuse of whitespace.
9+
10+
I propose we remove Phase 2 and handle the backslash character `\` as part of lexical elements.
1111

12-
2. Each instance of a backslash character (\) immediately followed by a new-line character is
13-
deleted, splicing physical source lines to form logical source lines. Only the last backslash on
14-
any physical source line shall be eligible for being part of such a splice. A source file that is
15-
not empty shall end in a new-line character, which shall not be immediately preceded by a
16-
backslash character before any such splicing takes place.
12+
## Current Text of Phase 2
1713

18-
## New text for phase 2
14+
2. Each instance of a backslash character (\) immediately followed by a newline character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. A source file that is not empty shall end in a newline character, which shall not be immediately preceded by a backslash character before any such splicing takes place.
1915

20-
2. Phase 2, responsable for line splicing has been removed in C2Y.
21-
The backslash character (\) followed by new line are now handled at phase 3.
16+
## New Text for Phase 2
2217

23-
## 6.4 Lexical elements
18+
2. Phase 2, responsible for line splicing, has been removed in C2Y. Phase 2 is empty in C2Y.
2419

25-
I propouse the backslash character (\) followed by spaces and new line to be handled inside
26-
string-literal, single line comment, comment and white spaces as follow.
20+
## 6.4 Lexical Elements
2721

22+
I propose that the backslash character `\` followed optionally by spaces and a newline be handled within string literals, single-line comments, multi-line comments, and whitespace as follows:
2823

29-
Backslash character (\) followed optionally by spaces and new line are part of comment and single-line comments.
24+
They will be part of comments
3025

3126
Sample:
3227

@@ -35,7 +30,7 @@ int main() {
3530
int i = 0;
3631
// See this path: c:\path\
3732
i = 2;
38-
return i; //always returns 2
33+
return i; // always returns 2
3934
}
4035
```
4136

@@ -45,36 +40,35 @@ int main() {
4540
\*********/
4641
```
4742

48-
Backslash character (\) followed optionally by spaces and new line are ignored inside literal strings
49-
Note: I will use · to represent the space character.
43+
They are parsed and ignored inside string literals
5044

5145
```c
52-
const·char·s =
46+
const·char·s·=·
5347
"·
5448
b";
5549
```
56-
Same as
50+
is the same as
5751

5852
```c
5953
const·char·s·=·
6054
"a·b";
6155
```
6256

63-
Backslash character (\) followed optionally by spaces and new line are ignored inside whitespaces
57+
They are parsed and ignored inside white spaces
6458

6559
```c
6660
const char s = 1·+·\···
6761
····2;
6862
```
69-
Same as
63+
is the same as
7064
```c
7165
const char s = 1·+·····2;
7266
```
7367

74-
## Breaking changes
75-
For all other tokens like idenfifiers, keywords, punctuators, constant the backslash character (\) is not accepct.
68+
## Breaking Changes
69+
For all other tokens like identifiers, keywords, and punctuators, the backslash character (`\`) is not accepted.
7670

77-
Currently we have
71+
Currently, we have
7872

7973
```c
8074
#define A\
@@ -85,12 +79,12 @@ This is the same as
8579
```c
8680
#define ABC
8781
```
88-
But if we had one space before B. This would be the same as
82+
But if we had one space before B, this would be the same as
83+
8984
```c
9085
#define A BC
9186
```
92-
With this proposal we have a error while parcing identifer A.
93-
This will promove clarification because the code will have to be write as
87+
With this proposal, we will have an error while parsing the identifier A. This will promote clarification because the code will have to be written as
9488
```c
9589
#define AB \
9690
C
@@ -100,23 +94,18 @@ or
10094
#define A B \
10195
C
10296
```
103-
Slicing punctuators and other tokens will be an error.
97+
Slicing punctuators and other tokens will result in an error.
10498
10599
```c
106-
int i;
107-
i+\
100+
int i;
101+
i+\
108102
+;
109103
```
110104

111-
112105
## References
113106

114-
Trimming whitespaces before line splicing
115-
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2223r2.pdf
116-
117-
118-
119-
107+
Trimming whitespace before line splicing:
108+
[https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2223r2.pdf](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2223r2.pdf)
120109

121110

122111

0 commit comments

Comments
 (0)