Skip to content

Commit 6ecd19c

Browse files
authored
Merge branch 'draft-v8' into default-interface-function-members
2 parents 5d5138a + 773fdb8 commit 6ecd19c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+849
-586
lines changed
248 KB
Binary file not shown.

.github/workflows/dependencies/ReplaceAndAdd.md

Lines changed: 47 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -33,88 +33,14 @@ the automatic section numbering tooling, they **must** be maintained manually.
3333
# Verification-Only Replacements & Additions
3434

3535
This set of replacements and additions is the bare minimum required to allow the grammar
36-
to verify and run, though
37-
it may not produce the desired parse (that requires at least the use of modes and/or
38-
lexical predicates).
36+
to verify and run, though it may not produce the desired lex and parse (that requires at
37+
least the use of modes and/or lexical predicates).
3938

40-
This set can be used as a basic check that the grammar is a correct ANTLR grammar.
39+
Pre-processing directives are skipped like whitespace, however lexing confirms the lexical
40+
grammar is valid.
4141

42-
---
43-
44-
## Top Level Rule
45-
46-
The Standard’s *compilation_unit* as is will allow garbage at the end of a file, this
47-
rule has an EOF requirement to ensure the whole of the input must be a correct program.
48-
49-
> *Note: The section number makes this the first rule in the grammar, not required but it
50-
has to go somewhere…*
51-
52-
### 0.0.0 Top Level Rule
53-
54-
```ANTLR
55-
// [ADDED] Rule added as the start point
56-
prog: compilation_unit EOF;
57-
```
58-
---
59-
60-
## Discarding Whitespace
61-
62-
The following changes in §7.3.2, §7.3.3 and §7.3.4, add `-> skip` to the “whitespace”
63-
token rules so that are not passed to the parser. This behaviour is implicit in the
64-
Standard.
65-
66-
### 6.3.2 Line terminators
67-
68-
```ANTLR
69-
// [SKIP]
70-
New_Line
71-
: ( New_Line_Character
72-
| '\u000D\u000A' // carriage return, line feed
73-
) -> skip
74-
;
75-
```
76-
77-
### 6.3.3 Comments
78-
79-
```ANTLR
80-
// [SKIP]
81-
Comment
82-
: ( Single_Line_Comment
83-
| Delimited_Comment
84-
) -> skip
85-
;
86-
```
87-
88-
### 6.3.4 White space
89-
90-
```ANTLR
91-
// [SKIP]
92-
Whitespace
93-
: ( [\p{Zs}] // any character with Unicode class Zs
94-
| '\u0009' // horizontal tab
95-
| '\u000B' // vertical tab
96-
| '\u000C' // form feed
97-
) -> skip
98-
;
99-
100-
```
101-
102-
---
103-
104-
## Pre-processing directives
105-
106-
This change causes all pre-processor directives to be discarded, they don’t need to be
107-
processed to validate the grammar (processing them would exercise the *implementation*
108-
of the pre-processor, which is not part of the Standard).
109-
110-
### 6.5.1 General
42+
This set can be used as a basic check that the grammar is a valid ANTLR grammar.
11143

112-
```ANTLR
113-
// [CHANGE] Discard pre-processor directives
114-
PP_Directive
115-
: (PP_Start PP_Kind PP_New_Line) -> skip
116-
;
117-
```
11844

11945
---
12046

@@ -139,7 +65,39 @@ As MLR is not supported by ANTLR without this change the grammar would be reject
13965

14066
```ANTLR
14167
// [CHANGE] This removes a mutual left-recursion group which we have (currently?)
142-
// [CHANGE] decided to leave in the Standard. Without this change the grammar will fail.
68+
// [CHANGE] decided to leave in the Standard. Without this change the grammar will
69+
// [CHANGE] fail to verify.
70+
# Expect
71+
primary_no_array_creation_expression
72+
: literal
73+
| interpolated_string_expression
74+
| simple_name
75+
| parenthesized_expression
76+
| tuple_expression
77+
| member_access
78+
| null_conditional_member_access
79+
| invocation_expression
80+
| element_access
81+
| null_conditional_element_access
82+
| this_access
83+
| base_access
84+
| post_increment_expression
85+
| post_decrement_expression
86+
| object_creation_expression
87+
| delegate_creation_expression
88+
| anonymous_object_creation_expression
89+
| typeof_expression
90+
| sizeof_expression
91+
| checked_expression
92+
| unchecked_expression
93+
| default_value_expression
94+
| nameof_expression
95+
| anonymous_method_expression
96+
| pointer_member_access // unsafe code support
97+
| pointer_element_access // unsafe code support
98+
| stackalloc_expression
99+
;
100+
# ReplaceWith
143101
primary_no_array_creation_expression
144102
: literal
145103
| interpolated_string_expression
@@ -194,12 +152,20 @@ primary_no_array_creation_expression
194152
## Interpolated strings
195153

196154
The lexical rules for interpolated strings are context-sensitive and are not ANLTR-ready in the Standard
197-
as how such rules are handled is an implementation detail, e.g. using ANTLR modes as done in mods-base.
155+
as how such rules are handled is an implementation detail, e.g. using ANTLR modes.
198156
Here we just define one token in terms of another to remove the overlap warnings.
199157

200158
### 12.8.3 Interpolated string expressions
201159

202160
```ANTLR
161+
// [CHANGE] This allows the grammar to verify without warnings, it does NOT correctly
162+
// [CHANGE] parse interpolated strings – that requires modes and/or lexical predicates.
163+
// [CHANGE] Note: Interpolated strings are properly parsed in Base and other sets.
164+
# Expect
165+
Interpolated_Verbatim_String_End
166+
: '"'
167+
;
168+
# ReplaceWith
203169
Interpolated_Verbatim_String_End
204170
: Interpolated_Regular_String_End
205171
;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This GitHub Action workflow is triggered on label changes for pull requests.
2+
# When a pull request is labeled with "DO NOT MERGE", the workflow fails, thus
3+
# preventing the pull request from being merged. Otherwise, the workflow will
4+
# succeed, allowing the pull request to be merged.
5+
6+
name: "Check labels that prevent merge"
7+
on:
8+
pull_request:
9+
branches: [main]
10+
types: [labeled, unlabeled]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
labels-preventing-merge-check:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
label:
21+
# Labels that prevent merging
22+
- 'do not merge'
23+
steps:
24+
- name: Harden Runner
25+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
26+
with:
27+
egress-policy: audit
28+
29+
- name: 'Check "${{ matrix.label }}" label'
30+
run: |
31+
echo "::notice::Merging permission is diabled for PRs when the '${{ matrix.label }}' label is applied."
32+
33+
if [ "${{ contains(github.event.pull_request.labels.*.name, matrix.label) }}" = "true" ]; then
34+
echo "::error::Pull request is labeled as '${{ matrix.label }}'. Please remove the label before merging."
35+
exit 1
36+
else
37+
exit 0
38+
fi

.github/workflows/grammar-validator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
# Install build grammar global tool
3535
- name: Install BuildGrammar tool
3636
run: |
37-
dotnet tool install --version 1.0.0-alpha.4 --global --add-source ./.github/workflows/dependencies/ EcmaTC49.BuildGrammar
37+
dotnet tool install --version 2.0.0-beta.3 --global --add-source ./.github/workflows/dependencies/ EcmaTC49.BuildGrammar
3838
3939

4040
- name: run validate

.github/workflows/markdown-links-verifier.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/workflows/renumber-sections.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
checks: write
19+
pull-requests: write
1920
env:
2021
DOTNET_NOLOGO: true
2122
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-examples.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ on:
1616
jobs:
1717
test-extraction-and-runner:
1818
runs-on: ubuntu-latest
19+
permissions:
20+
checks: write
21+
pull-requests: write
1922
env:
2023
DOTNET_NOLOGO: true
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
2126

2227
steps:
2328
- name: Check out our repo

.github/workflows/word-converter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
permissions:
1818
checks: write
19+
pull-requests: write
1920
env:
2021
DOTNET_NOLOGO: true
2122
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,6 @@ test-grammar/
360360

361361
# don't checkin jar files:
362362
*.jar
363+
364+
# don't checkin launchSettings:
365+
**/launchSettings.json

admin/v8-feature-tracker.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ default interface methods ([MS Proposal](https://github.com/dotnet/csharplang/bl
1515
permit `stackalloc` in nested contexts ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/nested-stackalloc.md)) | [1056](https://github.com/dotnet/csharpstandard/pull/1056) | Completed | small | N/A |
1616
`notnull` constraint ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/notnull-constraint.md)) | [830](https://github.com/dotnet/csharpstandard/pull/830) | Completed | small | Done |
1717
null coalescing assignment ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/null-coalescing-assignment.md)) | [609](https://github.com/dotnet/csharpstandard/pull/609) | HELP NEEDED | small | N/A | See Issue [#737](https://github.com/dotnet/csharpstandard/issues/737)
18-
nullable reference types ([MS Proposal (from V9)](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/nullable-reference-types-specification.md) which supercedes ([MS Proposal (from V8)](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/nullable-reference-types.md)) |[700](https://github.com/dotnet/csharpstandard/pull/700) | Completed | large | Done | related to V8 "notnull" feature
18+
nullable reference types ([MS Proposal (from V9)](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-9.0/nullable-reference-types-specification.md) which supercedes ([MS Proposal (from V8)](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/nullable-reference-types.md)) |[700](https://github.com/dotnet/csharpstandard/pull/700), [1195](https://github.com/dotnet/csharpstandard/pull/1195) | Completed | large | Done | related to V8 "notnull" feature
1919
Obsolete on property accessor ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/obsolete-accessor.md)) | **no change needed** | Postponed | | N/A | See Issue [#375](https://github.com/dotnet/csharpstandard/issues/375)
2020
New kinds of pattern matching ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/patterns.md)) | [873](https://github.com/dotnet/csharpstandard/pull/873) | Completed | medium | Done | precedence table assumes "ranges and indices" has been merged
2121
ranges and indices ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/ranges.md)) | [605](https://github.com/dotnet/csharpstandard/pull/605) | Completed | medium | Done |
2222
readonly instance members ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/readonly-instance-members.md)) | [673](https://github.com/dotnet/csharpstandard/pull/673) | Completed | small | N/A |
23-
name shadowing in nested functions ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/shadowing-in-nested-functions.md)) | [608](https://github.com/dotnet/csharpstandard/pull/608) | Completed | small | N/A |
24-
static local functions ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/static-local-functions.md)) | [869](https://github.com/dotnet/csharpstandard/pull/869)| Completed | small | N/A |
23+
name shadowing in nested functions ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/shadowing-in-nested-functions.md)) | [608](https://github.com/dotnet/csharpstandard/pull/608) | Merged | small | N/A |
24+
static local functions ([MS Proposal](https://github.com/dotnet/csharplang/blob/main/proposals/csharp-8.0/static-local-functions.md)) | [869](https://github.com/dotnet/csharpstandard/pull/869)| Merged | small | N/A |
2525
Disposable ref structs [672](https://github.com/dotnet/csharpstandard/pull/672) | | **???** | | | Included in PR [606](https://github.com/dotnet/csharpstandard/pull/606); **Check this**

0 commit comments

Comments
 (0)