Skip to content
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

Fix ast::Assignment #63

Merged
merged 2 commits into from
Jan 20, 2024
Merged

Fix ast::Assignment #63

merged 2 commits into from
Jan 20, 2024

Conversation

jlapeyre
Copy link
Collaborator

@jlapeyre jlapeyre commented Jan 20, 2024

Replace Name with (Name | IndexedIdentifier) in the definition of AssignmentStmt in openqasm3.ungram. This generates a method indexed_identifier implemented for AssignmentStmt in nodes.rs. This allowed us to remove the handcoded method indexed_identifier in expr_ext.rs. The latter exisited because I was going 100 mph implementing things and sticking the method in by hand was easier than updating the ungram file.

The SyntaxNode underlying AssignmentStmt may have one or two Exprs. The last Expr is always the rhs. So we take this into account when we retrieve it.

There is enough information in the ungrammar specification to write the method described above automatically. But sourcgen_ast.rs does not have the logic to this at present.

See #59

There is no are two tests added here. We need some better tools to write tests. Doing it by hand is laborious. r-a has as native facility for reading tests in comments interspersed in the source code. When they fail, the location of the test in the source code is reported. This might be nice.

Replace `Name` with `(Name | IndexedIdentifier)` in the definition of
`AssignmentStmt` in openqasm3.ungram. This generates a method `indexed_identifier` implemented
for `AssignmentStmt` in nodes.rs. This allowed us to remove the handcoded method `indexed_identifier` in expr_ext.rs.
The latter exisited because I was going 100 mph implementing things and sticking the method in by hand was easier
than updating the ungram file.

The `SyntaxNode` underlying `AssignmentStmt` may have one or two `Expr`s. The last `Expr` is always the rhs.
So we take this into account when we retrieve it.

There is enough information in the ungrammar specification to write the method described above automatically.
But sourgen_ast.rs does not have the logic to this at present.
I said I would not, but here it is.
@jlapeyre jlapeyre merged commit d7fec5d into main Jan 20, 2024
7 checks passed
@jlapeyre jlapeyre deleted the fix-assign branch February 2, 2024 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant