-
Notifications
You must be signed in to change notification settings - Fork 50
Refactor AST into a struct containing AST.Node enum #130
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
Conversation
@swift-ci please test Linux |
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
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.
@rxwei Does it make sense to include the copyright notice here? As otherwise it gets removed when re-running the generator.
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.
Yes it does. I'm already adding it here: #114, but the PR is blocked until there's a new toolchain.
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.
It might be better not to change this so that I won't have to resolve conflicts for my chain of 3 PRs 😂
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.
Yeah I was just thinking that, though I think there will still be a conflict as I'm still changing Concatenation.swift, but at least that can be resolved by re-running the generator
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.
LGTM
@@ -127,7 +127,7 @@ extension Parser { | |||
} | |||
fatalError("Unhandled termination condition") | |||
} | |||
return ast | |||
return .init(ast) |
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.
Where do global options come in?
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.
We'll parse them here and store them on AST
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.
Oh, right, that will be based on top of this. SGTM
Introduce `AST` as a new root type, with `AST.Node` becoming the type used to represent a particular node in the AST. This will allow us to store top-level state on the `AST` type rather than for each `AST.Node`.
Fix places that are currently producing and consuming AST nodes to use `AST.Node` instead of `AST`. This requires adding entry-points for both `AST` and `AST.Node` for: - renderAsCanonical - printAsCanonical - printAsPattern - _render(in:)
0e7cb24
to
7ca9a9a
Compare
@swift-ci please test Linux |
1 similar comment
@swift-ci please test Linux |
Introduce
AST
as a new root type, withAST.Node
becoming the type used to represent a particular node in the AST. This will allow us to store top-level state on theAST
type rather than for eachAST.Node
.