-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor antlr tool #207
Refactor antlr tool #207
Conversation
Rework the bat file to generate an ANTLR file, and update the grammar in the standard. Note that this does pick up a couple PRs that affected the grammar.
I think this will help us validate the grammar and fix validation errors.
tools/GetGrammar/grammar.antlr
Outdated
@@ -0,0 +1,2274 @@ | |||
|
|||
// Source: 7.3.1 General |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RexJaeschke @jskeet @gafter Will these comments help us to validate the ANTLR grammar? I added them to Rex's work on the grammar extraction tool because they helped me get started. I can leave this output in place if we think it will be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regardless of validation, I like the idea of keeping them just to make things easier for anyone reading the standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep; looks good to me.
Marking this ready for review. See #217 for my proposal on what to do next. /cc @RexJaeschke @jskeet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits, but otherwise fab.
@@ -10,6 +10,7 @@ This annex contains the grammar productions found in the specification, includin | |||
|
|||
```ANTLR | |||
|
|||
// Source: §7.3.1 General |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wonderful
tools/GetGrammar/Program.cs
Outdated
while ((inputLine = Console.ReadLine()) != null) | ||
{ | ||
if (inputLine.Length < 8) // Is it long enough to contain an opening fence? | ||
while ((inputLine = await inputFile.ReadLineAsync()) != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a new pattern yesterday:
while (await inputFile.ReadLineAsync() is string inputLine)
(and remove the earlier declaration).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet!
I'm making updates to the grammar extraction tool and batch file to make this easier to run as a github action.