Skip to content

Commit 82f553c

Browse files
authored
Merge pull request #535 from BillWagner/merge-v6
Merge v6 standard updates into the v7 branch
2 parents 9cc85b0 + f2b4eed commit 82f553c

File tree

106 files changed

+14870
-10139
lines changed

Some content is hidden

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

106 files changed

+14870
-10139
lines changed

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain
Binary file not shown.
Binary file not shown.
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Replacements & Additions
2+
3+
A “replacement & additions” file can be passed to `BuildGrammar`’s `--modification-file`/`-m`
4+
option and contains replacement and additional rules to be added to: verify/test a grammar,
5+
explore/test new language features, etc. It is a markdown (`.md`) file which follows the same
6+
conventions as those used for the Standard.
7+
8+
The file is processed by `BuildGrammar` similarly to other markdown files; clauses are
9+
noted and text in ```` ```ANTLR ... ``` ```` code blocks is “parsed” (being generous here);
10+
as ANTLR rules, mode commands, and comments (and nothing else, don’t go trying to set options
11+
or other stuff); and added to the corresponding section in the produced grammar (`.g4`) file.
12+
13+
The rules add to, or replace, existing rules in the corresponding clause; new rules are added
14+
to the end of the clause’s rule list, replacements occur in-place. Further in the replacement
15+
case the previous rule is kept as a comment, and this happens regardless of the previous rules
16+
clause i.e. a replacement can move a rule to a different clause.
17+
18+
A rule is only a replacement if it changes the rule’s definition or clause.
19+
Rules with are neither additions or replacements are ignored.
20+
21+
> *Note:* This means that a
22+
replacement & additions file can actually be a complete Standard section markdown file
23+
and only the changed rules will be extracted to update the grammar. So while working, say,
24+
on a PR if the original Standard’s section files are passed to `BuildGrammar` as input files,
25+
the section files changed by the PR are passed as modification files, then the resultant grammar will
26+
reflect the PR’s changes with the old rules as comments.
27+
28+
> **Important:** section numbers in replacement & additions files are not maintained by
29+
the automatic section numbering tooling, they **must** be maintained manually.
30+
31+
---
32+
33+
# Verification-Only Replacements & Additions
34+
35+
This set of replacements and additions is the bare minimum required to allow the grammar to verify and run, though
36+
it may not produce the desired parse (that requires at least the use of modes and/or
37+
lexical predicates).
38+
39+
This set can be used as a basic check that the grammar is a correct ANTLR grammar.
40+
41+
---
42+
43+
## Top Level Rule
44+
45+
The Standard’s *compilation_unit* as is will allow garbage at the end of a file, this
46+
rule has an EOF requirement to ensure the whole of the input must be a correct program.
47+
48+
> *Note: The section number makes this the first rule in the grammar, not required but it
49+
has to go somewhere…*
50+
51+
### 0.0.0 Top Level Rule
52+
53+
```ANTLR
54+
// [ADDED] Rule added as the start point
55+
prog: compilation_unit EOF;
56+
```
57+
---
58+
59+
## Discarding Whitespace
60+
61+
The following changes in §7.3.2, §7.3.3 and §7.3.4, add `-> skip` to the “whitespace”
62+
token rules so that are not passed to the parser. This behaviour is implicit in the
63+
Standard.
64+
65+
### 7.3.2 Line terminators
66+
67+
```ANTLR
68+
// [SKIP]
69+
New_Line
70+
: ( New_Line_Character
71+
| '\u000D\u000A' // carriage return, line feed
72+
) -> skip
73+
;
74+
```
75+
76+
### 7.3.3 Comments
77+
78+
```ANTLR
79+
// [SKIP]
80+
Comment
81+
: ( Single_Line_Comment
82+
| Delimited_Comment
83+
) -> skip
84+
;
85+
```
86+
87+
### 7.3.4 White space
88+
89+
```ANTLR
90+
// [SKIP]
91+
Whitespace
92+
: ( [\p{Zs}] // any character with Unicode class Zs
93+
| '\u0009' // horizontal tab
94+
| '\u000B' // vertical tab
95+
| '\u000C' // form feed
96+
) -> skip
97+
;
98+
99+
```
100+
101+
---
102+
103+
## Pre-processing directives
104+
105+
This change causes all pre-processor directives to be discarded, they don’t need to be
106+
processed to validate the grammar (processing them would exercise the *implementation*
107+
of the pre-processor, which is not part of the Standard).
108+
109+
### 7.5.1 General
110+
111+
```ANTLR
112+
// [CHANGE] Discard pre-processor directives
113+
PP_Directive
114+
: (PP_Start PP_Kind PP_New_Line) -> skip
115+
;
116+
```
117+
118+
---
119+
120+
## Mutual Left Recursion Removal
121+
122+
All but one mutual left recursive (MLR) group has been removed from the grammar (and we should
123+
strive not to introduce any new ones).
124+
125+
This change resolves the one remaining MLR group by inlining some of the non-terminal
126+
alternatives in *primary_no_array_creation_expression*.
127+
128+
Non-terminals that are inlined are commented out and the inlined body is indented.
129+
130+
This change has not been made to the Standard itself as it makes *primary_no_array_creation_expression*
131+
“uglier” and would obfuscate somewhat the description in the Standard.
132+
133+
As MLR is not supported by ANTLR without this change the grammar would be rejected.
134+
135+
### 12.7.1 General
136+
137+
```ANTLR
138+
// [CHANGE] This removes a mutual left-recursion group which we have (currently?)
139+
// [CHANGE] decided to leave in the Standard. Without this change the grammar will fail.
140+
primary_no_array_creation_expression
141+
: literal
142+
| simple_name
143+
| parenthesized_expression
144+
// | member_access
145+
| primary_no_array_creation_expression '.' identifier type_argument_list?
146+
| array_creation_expression '.' identifier type_argument_list?
147+
| predefined_type '.' identifier type_argument_list?
148+
| qualified_alias_member '.' identifier type_argument_list?
149+
// | invocation_expression
150+
| primary_no_array_creation_expression '(' argument_list? ')'
151+
| array_creation_expression '(' argument_list? ')'
152+
// | element_access and pointer_element_access (unsafe code support)
153+
| primary_no_array_creation_expression '[' argument_list ']'
154+
| this_access
155+
| base_access
156+
// | post_increment_expression
157+
| primary_no_array_creation_expression '++'
158+
| array_creation_expression '++'
159+
// | post_decrement_expression
160+
| primary_no_array_creation_expression '--'
161+
| array_creation_expression '--'
162+
| object_creation_expression
163+
| delegate_creation_expression
164+
| anonymous_object_creation_expression
165+
| typeof_expression
166+
| sizeof_expression
167+
| checked_expression
168+
| unchecked_expression
169+
| default_value_expression
170+
| nameof_expression
171+
| anonymous_method_expression
172+
// | pointer_member_access // unsafe code support
173+
| primary_no_array_creation_expression '->' identifier type_argument_list?
174+
| array_creation_expression '->' identifier type_argument_list?
175+
// | pointer_element_access // unsafe code support
176+
// covered by element_access replacement above
177+
;
178+
```
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: ANTLR Grammar validator
2+
3+
# Triggers the workflow on pull request events that update the branch
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
workflow_dispatch:
8+
inputs:
9+
reason:
10+
description: 'The reason for running the workflow'
11+
required: true
12+
default: 'Manual run'
13+
14+
jobs:
15+
grammar-validator:
16+
runs-on: ubuntu-18.04
17+
env:
18+
DOTNET_NOLOGO: true
19+
20+
steps:
21+
- name: Check out our repo
22+
uses: actions/checkout@v2
23+
24+
- name: Setup .NET 6.0
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: 6.0.x
28+
29+
- name: Set up JDK 15
30+
uses: actions/setup-java@v1
31+
with:
32+
java-version: 15.0
33+
34+
# Install build grammar global tool
35+
- name: Install BuildGrammar tool
36+
run: |
37+
dotnet tool install --version 1.0.0-alpha.1 --global --add-source ./.github/workflows/dependencies/ EcmaTC49.BuildGrammar
38+
39+
40+
- name: run validate
41+
run: |
42+
cd tools
43+
./validate-grammar.sh
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Markdown links verifier
2+
on: pull_request
3+
4+
jobs:
5+
validate_links:
6+
name: Markdown links verifier
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout the repository
11+
uses: actions/checkout@v1
12+
13+
- name: Validate links
14+
uses: Youssef1313/[email protected]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "markdownlint",
5+
"pattern": [
6+
{
7+
"regexp": "^([^:]*):(\\d+):?(\\d+)?\\s([\\w-\\/]*)\\s(.*)$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"code": 4,
12+
"message": 5
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/markdownlint.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Markdownlint
2+
3+
on:
4+
push:
5+
branches:
6+
- draft-v6
7+
paths:
8+
- "standard/*.md"
9+
- ".markdownlint.json"
10+
pull_request:
11+
paths:
12+
- "standard/*.md"
13+
- ".markdownlint.json"
14+
workflow_dispatch:
15+
inputs:
16+
reason:
17+
description: 'The reason for running the workflow'
18+
required: true
19+
default: 'Manual run'
20+
21+
jobs:
22+
lint:
23+
24+
runs-on: ubuntu-latest
25+
permissions:
26+
statuses: write
27+
28+
steps:
29+
- uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675 #@v2
30+
- name: Use Node.js
31+
uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d #@v1
32+
with:
33+
node-version: 12.x
34+
- name: Run Markdownlint
35+
run: |
36+
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
37+
npm i -g markdownlint-cli
38+
markdownlint "standard/*.md"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Renumber standard TOC
2+
3+
# Triggers the workflow on pull request events that update the branch
4+
on:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
workflow_dispatch:
8+
inputs:
9+
reason:
10+
description: 'The reason for running the workflow'
11+
required: true
12+
default: 'Manual run'
13+
14+
jobs:
15+
renumber-sections:
16+
runs-on: ubuntu-18.04
17+
env:
18+
DOTNET_NOLOGO: true
19+
20+
steps:
21+
- name: Check out our repo
22+
uses: actions/checkout@v2
23+
24+
- name: Setup .NET 6.0
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: 6.0.x
28+
29+
- name: Run section renumbering dry run
30+
run: |
31+
cd tools
32+
./run-section-renumber.sh --dryrun

0 commit comments

Comments
 (0)