You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/remove_phase_2.md
+30-41Lines changed: 30 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,27 @@
1
-
## Removing Phase 2
1
+
2
+
## Removal of Phase 2
2
3
3
4
### Motivation
4
5
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.
9
7
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.
11
11
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
17
13
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.
19
15
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
22
17
23
-
## 6.4 Lexical elements
18
+
2. Phase 2, responsible for line splicing, has been removed in C2Y. Phase 2 is empty in C2Y.
24
19
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
27
21
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:
28
23
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
30
25
31
26
Sample:
32
27
@@ -35,7 +30,7 @@ int main() {
35
30
int i = 0;
36
31
// See this path: c:\path\
37
32
i = 2;
38
-
return i; //always returns 2
33
+
return i; //always returns 2
39
34
}
40
35
```
41
36
@@ -45,36 +40,35 @@ int main() {
45
40
\*********/
46
41
```
47
42
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
50
44
51
45
```c
52
-
const·char·s =
46
+
const·char·s·=·
53
47
"a·\··
54
48
b";
55
49
```
56
-
Same as
50
+
is the same as
57
51
58
52
```c
59
53
const·char·s·=·
60
54
"a·b";
61
55
```
62
56
63
-
Backslash character (\) followed optionally by spaces and new line are ignored inside whitespaces
57
+
They are parsed and ignored inside white spaces
64
58
65
59
```c
66
60
constchar s = 1·+·\···
67
61
····2;
68
62
```
69
-
Same as
63
+
is the same as
70
64
```c
71
65
constchar s = 1·+·····2;
72
66
```
73
67
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.
76
70
77
-
Currently we have
71
+
Currently, we have
78
72
79
73
```c
80
74
#defineA\
@@ -85,12 +79,12 @@ This is the same as
85
79
```c
86
80
#defineABC
87
81
```
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
+
89
84
```c
90
85
#defineA BC
91
86
```
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
94
88
```c
95
89
#define AB \
96
90
C
@@ -100,23 +94,18 @@ or
100
94
#defineA B \
101
95
C
102
96
```
103
-
Slicing punctuators and other tokens will be an error.
97
+
Slicing punctuators and other tokens will result in an error.
0 commit comments