Getting information about syntactic errors

Hi, we’re working on getting syntactic errors from queries, with our Lezer grammar.

In this, we have a query like below, where replace and api are misspelled as ‘replac’ and ‘ap’,

create or replac ap integration foobar
    api_provider=aws_api_gateway
    api_aws_role_arn='arn:aws:iam::123456789012:role/my_cloud_account_role'
    api_allowed_prefixes=('https://xyz.execute-api.us-west-2.amazonaws.com/production')
    enabled=true;

these are the errors we get.

Only the first two are wanted since the rest of tokens are okay. Is there any way to retrieve only the ‘important’ errors, for example the ones that are mis-spelled?

Errors:
Error near replac
Error near ap
Error near integration
Error near foobar
Error near api_provider
Error near =
Error near aws_api_gateway
Error near api_aws_role_arn
Error near =
Error near ‘arn:aws:iam::123456789012:role/my_cloud_account_role’
Error near api_allowed_prefixes
Error near =
Error near (
Error near ‘https://xyz.execute-api.us-west-2.amazonaws.com/production
Error near )
Error near enabled
Error near =
Error near true
Error near ;

Is this mainly due to error insensitivity of the Lezer parser system? We ran this with a different parser, and the result was, only the first mis-spelled instance pointed as an error, so only Error near replace.

Is it possible to stop this “cascading” of errors?

No. The parser isn’t always able to figure out the most likely parse, and might just completely lose its way for some kinds of invalid syntax.

1 Like