kaj/rsass

Returning spans when parsing

Closed this issue · 3 comments

Hey!

For reasons outlined in connorskees/grass#50 , I'm looking to parse some Sass and be able to generate tooling with descriptive errors based on my own custom needs and lints.

It looks like I can get back a Vec<Item>, however if I decide that one of those items doesn't meet my criteria I can't print an error saying what file and line number it came from.

I'd like to be able to get access to something like:

struct ParsedItem {
    path: PathBuf,
    span: Span, // line number and column number
    item: Item,
}

Would exposing this information align with the goals of rsass?

Thanks!

kaj commented

Some Item variants have a SourcePos in them for possible error reporting. Having a pos for every item seems nicely consistent, but would it be enough? wouldn't specific positions for different parts of the item be needed in some cases?

Yeah I'd say that ideally every token has position information. i.e. selectors would have tokens.

I'm actually just using CSS now, at least for the time being, so feel free to close out this issue if you like.

Thanks!

kaj commented

There will be positions noted for more Items and Values before rsass reaches 1.0, but I'm closing this specific issue.