Comments (5)
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.
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.
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.
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.
This seems to be a duplicate of #270.
from fluent-rs.
Related Issues (20)
- ResourceManager ignores and hides errors
- ResourceManager needs to implement BundleGenerator HOT 2
- Parser swallows leading whitespace after indented placeable HOT 2
- Clippy should be run in CI HOT 2
- rustmt should be run in CI
- error[E0277]: `(dyn Any + 'static)` cannot be sent between threads safely HOT 11
- Cannot use built-in functions HOT 2
- Which data providers Fluent crates use? HOT 3
- Make FluentArgs a trait? HOT 1
- Switching windows process/thread ui languages HOT 2
- Provide Way to Avoid Allocating To Collect Formatting Errors HOT 7
- Using or switching to icu4x crates? HOT 4
- Output looks the same, but is different HOT 3
- Behaviour of FluentArgs::set is misleading HOT 1
- Support full precision of all numbers HOT 1
- How to use this in a command line program and properly parse POSIX locales? HOT 1
- [Feature request] Allow serialize all AST types instead of just Resource HOT 7
- Does a 'safe harbor' release of the current HEAD make sense before further changes? HOT 12
- Precompiling and Embedding Resources for Performance Optimization HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-rs.