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 propagation #1181

Open
OmarTawfik opened this issue Dec 5, 2024 · 0 comments
Open

Query parser error propagation #1181

OmarTawfik opened this issue Dec 5, 2024 · 0 comments
Assignees

Comments

@OmarTawfik
Copy link
Contributor

The following query is incorrect, as the variant: filter should be applied to each literal in the choices:

Query::parse(
    "[PathImport
        path: [StringLiteral
            @variant variant: ([DoubleQuotedStringLiteral] | [SingleQuotedStringLiteral])
        ]
    ]",
)

It would produce this error:

"Parse error:
expected ']' at: path: [StringLiteral
            @variant variant: ([DoubleQuotedStringLiteral] | [SingleQuotedStringLiteral])
                ]
            ]
Alt at: [PathImport
                path: [StringLiteral
            @variant variant: ([DoubleQuotedStringLiteral] | [SingleQuotedStringLiteral])
                ]
            ]
"

The correct version would be:

Query::parse(
    "[PathImport
        path: [StringLiteral
            @variant (variant: [DoubleQuotedStringLiteral] | variant: [SingleQuotedStringLiteral])
        ]
    ]",
)

However, the error position is inaccurate, as it points to the parent PathImport node, rather than being narrowed down to the specific ( ) node that has the error. We should look into the nom error propagation in crates/metaslang/cst/src/query/parser.rs, and see if we can control/improve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ⏳ Todo
Development

No branches or pull requests

2 participants