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

Query parser error reporting improvements #1052

Merged
merged 10 commits into from
Aug 2, 2024

Conversation

ggiraldez
Copy link
Contributor

Fixes #1041
Fixes #1042

This PR improves on the query parse errors reported:

  • Compute row and column information for query parser errors (previously these were not computed and hard-coded to 0,0)

  • Improve reporting when the error occurs attempting to parse edge labels or node kinds: By using cut() and providing a context() we can get a better error message without fully customizing the error type used throughout the parser.

@ggiraldez ggiraldez requested a review from a team as a code owner July 30, 2024 22:47
Copy link

changeset-bot bot commented Jul 30, 2024

🦋 Changeset detected

Latest commit: 9689b21

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@nomicfoundation/slang Patch
@nomicfoundation/slang-darwin-arm64 Patch
@nomicfoundation/slang-darwin-x64 Patch
@nomicfoundation/slang-linux-arm64-gnu Patch
@nomicfoundation/slang-linux-arm64-musl Patch
@nomicfoundation/slang-linux-x64-gnu Patch
@nomicfoundation/slang-linux-x64-musl Patch
@nomicfoundation/slang-win32-arm64-msvc Patch
@nomicfoundation/slang-win32-ia32-msvc Patch
@nomicfoundation/slang-win32-x64-msvc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few questions/suggestions.
Thanks!

crates/metaslang/cst/src/query/parser.rs Outdated Show resolved Hide resolved
crates/metaslang/cst/src/query/parser.rs Outdated Show resolved Hide resolved
crates/metaslang/cst/src/query/parser.rs Show resolved Hide resolved
crates/metaslang/cst/src/query/parser.rs Outdated Show resolved Hide resolved
crates/metaslang/cst/src/query/parser.rs Outdated Show resolved Hide resolved
crates/metaslang/cst/src/query/parser.rs Show resolved Hide resolved
@ggiraldez ggiraldez requested a review from OmarTawfik July 31, 2024 15:26
Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remaining suggestion about the error message.
Otherwise, LGTM!

@ggiraldez ggiraldez requested a review from OmarTawfik August 1, 2024 18:59
Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!
This will greatly improve the DX working with the queries.

@OmarTawfik OmarTawfik added this pull request to the merge queue Aug 2, 2024
Merged via the queue into NomicFoundation:main with commit 54c9067 Aug 2, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Aug 2, 2024
ggiraldez added a commit to manastech/slang that referenced this pull request Aug 6, 2024
Fixes NomicFoundation#1041
Fixes NomicFoundation#1042 

This PR improves on the query parse errors reported:

- Compute row and column information for query parser errors (previously
these were not computed and hard-coded to 0,0)

- Improve reporting when the error occurs attempting to parse edge
labels or node kinds: By using `cut()` and providing a `context()` we
can get a better error message without fully customizing the error type
used throughout the parser.
github-merge-queue bot pushed a commit that referenced this pull request Aug 7, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

## @nomicfoundation/[email protected]

### Minor Changes

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: queries now ignore trivia nodes.

- [#1030](#1030)
[`7e467ce`](7e467ce)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: remove the ellipsis query `...` operator making it implicit,
add an adjacency operator `.`.

### Patch Changes

- [#1015](#1015)
[`369ee30`](369ee30)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - upgrade to rust
`1.79.0`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Compute row and column information for query parser errors.

- [#1048](#1048)
[`c408caa`](c408caa)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - support Yul
multiple variables declaration

- [#1047](#1047)
[`2b32045`](2b32045)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - inline
`MemberAccess` enum into the parent `MemberAccessExpression`

- [#1062](#1062)
[`6b05496`](6b05496)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix stack
assignments operator `=:`.

- [#1052](#1052)
[`54c9067`](54c9067)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - Tree Query
Language: Improve reporting when an error occurs attempting to parse
edge labels or node kinds.

- [#1037](#1037)
[`2a74f91`](2a74f91)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - fix
`ExponentiationExpression` associativity before `0.8.0`

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

misleading QueryError on misspelled labels or kinds QueryError missing correct row/column information
2 participants