syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Rust plugin missing token location support

Open TokenGuard opened this issue 6 years ago • 3 comments

Hi, I am currently trying to implement a parser in Rust using Syntax, but when I run Syntax with the --loc option rustc just complains that it cannot find a definition of Loc anywhere, which from what I gather is the struct that extracts location information from the file.

I haven't been able to find any documentation of this feature for the Rust plugin so my question is should the definition of Loc be supplied by the end user, or should it be auto-generated just as the rest of the parser?

TokenGuard avatar Oct 25 '19 11:10 TokenGuard

Hi Bence,

Thanks for the report. It seems Rust plugin doesn't support generating locations at the moment, I don't see Loc struct definition in the templates, but I do seem some rewrites are happening at https://github.com/DmitrySoshnikov/syntax/blob/master/src/plugins/rust/rust-parser-generator-trait.js#L352 -- Loc::from_tokens_range . Probably I wanted to implement Loc for Rust, but then postponed it. Worth opening an issue on GitHub for this, so we can add it.

In general --loc is pretty limited only to some plugins (e.g. it works JavaScript, but not for Rust yet).

Dmitry

On Fri, Oct 25, 2019 at 4:50 AM Bence Babrian [email protected] wrote:

Hi, I am currently trying to implement a parser in Rust using Syntax, but when I run Syntax with the --loc option rustc just complains that it cannot find a definition of Loc anywhere, which from what I gather is the struct that extracts location information from the file.

I haven't been able to find any documentation of this feature for the Rust plugin so my question is should the definition of Loc be supplied by the end user, or should it be auto-generated just as the rest of the parser?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DmitrySoshnikov/syntax/issues/85?email_source=notifications&email_token=AAB3SKX3TRGZHGJTO7BFE63QQLMRZA5CNFSM4JFCLKJKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HULWV7Q, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB3SKWR2JQQFU3ZHKZUFLLQQLMRZANCNFSM4JFCLKJA .

DmitrySoshnikov avatar Oct 26 '19 02:10 DmitrySoshnikov

Are there any plans to add this location support?

FranklinChen avatar Nov 20 '20 01:11 FranklinChen

No immediate plans yet, but depending on demand, we can allocate time adding support for it.

DmitrySoshnikov avatar Nov 20 '20 20:11 DmitrySoshnikov