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

the error position isn't accurate #870

Open
taodongl opened this issue Jun 18, 2023 · 3 comments
Open

the error position isn't accurate #870

taodongl opened this issue Jun 18, 2023 · 3 comments

Comments

@taodongl
Copy link

taodongl commented Jun 18, 2023

Describe the bug
I want to use pest to analyze syntax issue of files (I used to deal with it using Antlr in Java lang),
but I can't get right position.

To Reproduce

use pest::Parser;
use pest_grammars::json::*;

const DATA: &str = r#"{"name": "hello, the\' world"}"#;

fn main() {
    let ret = JsonParser::parse(Rule::json, DATA);
    println!("{:?}", ret);
}

Expected behavior

{"name": "hello, the\' world"}
                    ^--- issue position

Current behavior

{"name": "hello, the\' world"}
         ^--- issue position
@taodongl taodongl added the bug label Jun 18, 2023
@tomtau
Copy link
Contributor

tomtau commented Jun 18, 2023

I guess it's because it points to the beginning of the rule where the issue occurred?

@taodongl
Copy link
Author

@tomtau oh yes, my example isn't good (pest and antlr report the same position).
I use a new json example:

{"name": "hello, the" world"}

For pest: location: Pos(0), line_col: Pos((1, 1))
For antlr: line 1:22 token recognition error at: 'w'

@tomtau
Copy link
Contributor

tomtau commented Dec 29, 2023

BTW a similar issue: #955 which was resolved by correcting the grammar.

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

No branches or pull requests

2 participants