Giter Club home page Giter Club logo

Comments (5)

zbraniecki avatar zbraniecki commented on June 6, 2024 2

Ugh, I understand what you're trying to achieve but the architecture is particularly not suited for that. We do not associate AST with any textual representation, and binding AST to offsets would do just that.

If you were able to achieve adding that without inducing performance, memory penalty or increasing AST maintenance complexity, I'd be open to that, but I'm concerned it won't be easy to do.

For your particular purpose, you could extend the parser to handle optional visitor/inspect callback before inserting an entry to the AST, and check if it's an ID that already has been added.
I know it's not perfect, but parser is tied to source format, resulting AST is not.

from fluent-rs.

zbraniecki avatar zbraniecki commented on June 6, 2024 1

Sure, I'd like to just ask for a good design that minimizes the maintenance burden. I don't want to have each edit to AST/parser be slowed down by source position considerations.

Maybe a trait that can be implemented on each node and parser #[cfg(...)]node.setPositionInSource(offset) ?

from fluent-rs.

wiiznokes avatar wiiznokes commented on June 6, 2024

For your particular purpose, you could extend the parser to handle optional visitor/inspect callback before inserting an entry to the AST, and check if it's an ID that already has been added.

while this could work, i'm also planning to do more verification like compare two files, so having to parse multiple times is not great.

I know it doesn't really fill the maintenance constraint but would a feature gate could be considered?

from fluent-rs.

wiiznokes avatar wiiznokes commented on June 6, 2024

But how will the offset be stored ?

I was thinking of something like #[cfg(...)] pos: usize, and then when parsing, we just need to insert the position #[cfg(...)] pos: self.ptr

To be clear, if the ast is changed, the positions will not be in sync, and the serializer will not take the offset into account.

from fluent-rs.

alerque avatar alerque commented on June 6, 2024

This seems to be a duplicate of #270.

from fluent-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.