-
Notifications
You must be signed in to change notification settings - Fork 50
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
Rethink AST API while considering syn #23
Comments
|
One thing that I noticed when implementing a very simple consumer of full_moon, is that there are a lot places where you need to destructure enums where by the design of the ast, there can only be one type of token, but that is not reflect in the types. I noticed this in particular for identifiers and string literals. I've been pondering how to one could handle this:
I presume you mean not using enum struct variants? It appears that enum uses tuple variants with a single struct as the value everywhere. If we did that for tokens (say), then we could store those structs directly in the ast for the appropriate nodes (possibly wrapped by a |
Yeah. Basically, instead of this: pub enum Index<'a> {
Brackets {
brackets: ContainedSpan<'a>,
expression: Expression<'a>,
},
Dot {
dot: Cow<'a, TokenReference<'a>>,
name: Cow<'a, TokenReference<'a>>,
},
} ...it would be: pub enum Index<'a> {
Brackets(IndexBrackets<'a>),
Dot(IndexDot<'a>),
} This turned out to look like it would be useful when I was implementing rlua bindings, since dealing with structs directly turned out to be way easier than the enum structs. |
syn, an established syntax tree library for Rust, has things like
Punctuated
and whatnot. Would be smart to look through what syn does and see how much of it full-moon should have.The text was updated successfully, but these errors were encountered: