Skip to content

Commit

Permalink
Merge branch 'draft-v8' into unmanaged-constructed-types
Browse files Browse the repository at this point in the history
  • Loading branch information
RexJaeschke authored Nov 13, 2024
2 parents 0e73020 + 773fdb8 commit c155346
Show file tree
Hide file tree
Showing 139 changed files with 6,356 additions and 3,910 deletions.
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/docs-feedback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Learn feedback control.
description: |
⛔ This template is hooked into the feedback control on the bottom of every page on the learn.microsoft.com site. It automatically fills in several fields for you. Don't use for other purposes. ⛔
body:
- type: markdown
attributes:
value: "## Issue information"
- type: markdown
attributes:
value: Select the issue type, and describe the issue in the text box below. Add as much detail as needed to help us resolve the issue. Make sure to include the relevant section number. The committee is working on C# 8 currently. Don't write issues about features added after that version.
- type: dropdown
id: issue-type
attributes:
label: Type of issue
options:
- Typo
- Spec incorrect
- Spec incomplete
- xref missing
- Other (describe below)
validations:
required: true
- type: textarea
id: feedback
validations:
required: true
attributes:
label: Description
- type: markdown
attributes:
value: "## 🚧 Document information 🚧"
- type: markdown
attributes:
value: "*Don't modify the following fields*. They are automatically filled in for you. Doing so will disconnect your issue from the affected article. *Don't edit them*."
- type: input
id: pageUrl
validations:
required: true
attributes:
label: Page URL
- type: input
id: contentSourceUrl
validations:
required: true
attributes:
label: Content source URL
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "nuget"
directory: "/tools" #tools.sln
schedule:
interval: "weekly"
day: "wednesday"
open-pull-requests-limit: 5
groups:
# Group .NET updates together for solutions.
dotnet:
patterns:
- "*" # Prefer a single PR per solution update.
Binary file not shown.
Binary file modified .github/workflows/dependencies/EcmaTC49.Smarten.tar
Binary file not shown.
160 changes: 77 additions & 83 deletions .github/workflows/dependencies/ReplaceAndAdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,88 +32,15 @@ the automatic section numbering tooling, they **must** be maintained manually.

# Verification-Only Replacements & Additions

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

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

---

## Top Level Rule

The Standard’s *compilation_unit* as is will allow garbage at the end of a file, this
rule has an EOF requirement to ensure the whole of the input must be a correct program.

> *Note: The section number makes this the first rule in the grammar, not required but it
has to go somewhere…*

### 0.0.0 Top Level Rule

```ANTLR
// [ADDED] Rule added as the start point
prog: compilation_unit EOF;
```
---

## Discarding Whitespace

The following changes in §7.3.2, §7.3.3 and §7.3.4, add `-> skip` to the “whitespace”
token rules so that are not passed to the parser. This behaviour is implicit in the
Standard.

### 7.3.2 Line terminators

```ANTLR
// [SKIP]
New_Line
: ( New_Line_Character
| '\u000D\u000A' // carriage return, line feed
) -> skip
;
```

### 7.3.3 Comments

```ANTLR
// [SKIP]
Comment
: ( Single_Line_Comment
| Delimited_Comment
) -> skip
;
```

### 7.3.4 White space

```ANTLR
// [SKIP]
Whitespace
: ( [\p{Zs}] // any character with Unicode class Zs
| '\u0009' // horizontal tab
| '\u000B' // vertical tab
| '\u000C' // form feed
) -> skip
;
```

---

## Pre-processing directives

This change causes all pre-processor directives to be discarded, they don’t need to be
processed to validate the grammar (processing them would exercise the *implementation*
of the pre-processor, which is not part of the Standard).
This set can be used as a basic check that the grammar is a valid ANTLR grammar.

### 7.5.1 General

```ANTLR
// [CHANGE] Discard pre-processor directives
PP_Directive
: (PP_Start PP_Kind PP_New_Line) -> skip
;
```

---

Expand All @@ -125,32 +52,73 @@ strive not to introduce any new ones).
This change resolves the one remaining MLR group by inlining some of the non-terminal
alternatives in *primary_no_array_creation_expression*.

Non-terminals that are inlined are commented out and the inlined body is indented.
Non-terminals that are inlined
are commented out and the inlined body is indented.

This change has not been made to the Standard itself as it makes *primary_no_array_creation_expression*
“uglier” and would obfuscate somewhat the description in the Standard.
“uglier” and would obfuscate somewhat the description in the Standard – both
subjective reasons of course...

As MLR is not supported by ANTLR without this change the grammar would be rejected.

### 12.7.1 General
### 12.8.1 General

```ANTLR
// [CHANGE] This removes a mutual left-recursion group which we have (currently?)
// [CHANGE] decided to leave in the Standard. Without this change the grammar will fail.
// [CHANGE] decided to leave in the Standard. Without this change the grammar will
// [CHANGE] fail to verify.
# Expect
primary_no_array_creation_expression
: literal
| interpolated_string_expression
| simple_name
| parenthesized_expression
| tuple_expression
| member_access
| null_conditional_member_access
| invocation_expression
| element_access
| null_conditional_element_access
| this_access
| base_access
| post_increment_expression
| post_decrement_expression
| object_creation_expression
| delegate_creation_expression
| anonymous_object_creation_expression
| typeof_expression
| sizeof_expression
| checked_expression
| unchecked_expression
| default_value_expression
| nameof_expression
| anonymous_method_expression
| pointer_member_access // unsafe code support
| pointer_element_access // unsafe code support
| stackalloc_expression
;
# ReplaceWith
primary_no_array_creation_expression
: literal
| interpolated_string_expression
| simple_name
| parenthesized_expression
| tuple_expression
// | member_access
| primary_no_array_creation_expression '.' identifier type_argument_list?
| array_creation_expression '.' identifier type_argument_list?
| predefined_type '.' identifier type_argument_list?
| qualified_alias_member '.' identifier type_argument_list?
// | null_conditional_member_access
| primary_no_array_creation_expression '?' '.' identifier type_argument_list? dependent_access*
| array_creation_expression '?' '.' identifier type_argument_list? dependent_access*
// | invocation_expression
| primary_no_array_creation_expression '(' argument_list? ')'
| array_creation_expression '(' argument_list? ')'
// | element_access and pointer_element_access (unsafe code support)
| primary_no_array_creation_expression '[' argument_list ']'
// | null_conditional_element_access
| primary_no_array_creation_expression '?' '[' argument_list ']' dependent_access*
| this_access
| base_access
// | post_increment_expression
Expand All @@ -174,5 +142,31 @@ primary_no_array_creation_expression
| array_creation_expression '->' identifier type_argument_list?
// | pointer_element_access // unsafe code support
// covered by element_access replacement above
| stackalloc_expression
;
```


---

## Interpolated strings

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

### 12.8.3 Interpolated string expressions

```ANTLR
// [CHANGE] This allows the grammar to verify without warnings, it does NOT correctly
// [CHANGE] parse interpolated strings – that requires modes and/or lexical predicates.
// [CHANGE] Note: Interpolated strings are properly parsed in Base and other sets.
# Expect
Interpolated_Verbatim_String_End
: '"'
;
# ReplaceWith
Interpolated_Verbatim_String_End
: Interpolated_Regular_String_End
;
```
38 changes: 38 additions & 0 deletions .github/workflows/do-not-merge-label-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This GitHub Action workflow is triggered on label changes for pull requests.
# When a pull request is labeled with "DO NOT MERGE", the workflow fails, thus
# preventing the pull request from being merged. Otherwise, the workflow will
# succeed, allowing the pull request to be merged.

name: "Check labels that prevent merge"
on:
pull_request:
branches: [main]
types: [labeled, unlabeled]

permissions:
contents: read

jobs:
labels-preventing-merge-check:
runs-on: ubuntu-latest
strategy:
matrix:
label:
# Labels that prevent merging
- 'do not merge'
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit

- name: 'Check "${{ matrix.label }}" label'
run: |
echo "::notice::Merging permission is diabled for PRs when the '${{ matrix.label }}' label is applied."
if [ "${{ contains(github.event.pull_request.labels.*.name, matrix.label) }}" = "true" ]; then
echo "::error::Pull request is labeled as '${{ matrix.label }}'. Please remove the label before merging."
exit 1
else
exit 0
fi
6 changes: 3 additions & 3 deletions .github/workflows/grammar-validator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
- name: Check out our repo
uses: actions/checkout@v2

- name: Setup .NET 6.0
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Set up JDK 15
uses: actions/setup-java@v1
Expand All @@ -34,7 +34,7 @@ jobs:
# Install build grammar global tool
- name: Install BuildGrammar tool
run: |
dotnet tool install --version 1.0.0-alpha.2 --global --add-source ./.github/workflows/dependencies/ EcmaTC49.BuildGrammar
dotnet tool install --version 2.0.0-beta.3 --global --add-source ./.github/workflows/dependencies/ EcmaTC49.BuildGrammar

- name: run validate
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/markdown-links-verifier.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/quest-bulk.yml

This file was deleted.

Loading

0 comments on commit c155346

Please sign in to comment.