Comments (5)
@TitanNano my plan right now (which is just in my head) is for Logos to expose trivia as just a string of bytes between the previous and current token, and have that string attached to few nodes where comments might be useful (functions, methods, variable declarations), so you could extract JSDoc comments out of it.
from ratel-core.
Oh this is clever! I like the idea of trivia being attached to nodes, I wouldn't necessarily do it on every node (although, given how fast Ratel is, it might not be that much of a burden), but doing it on things like functions should be sufficient. It would require some re-parsing of comments, but then any tool that wants to read documentation or JSDoc types from comments is likely going to have to parse those in full anyway.
from ratel-core.
BTW, I have a crate with implenets a similar flavor of syntax trees here: https://github.com/rust-analyzer/rowan
It's main focus is loselessness, and not perf, so it has a ton of indirection and allocation.
from ratel-core.
If you want to support not only comments, but white space as well, and in general support loseless syntax trees, I suggest taking a look at Swift’s libsyntax architecture:
https://github.com/apple/swift/tree/master/lib/Syntax.
This might not be what you want though: such full fidelity syntax trees are heavier than ASTs.
from ratel-core.
I use ratel to do some JavaScript type analysis and I'm going to need comments, so I can parse JSDoc annotations. Is this something you are interested to implement in the near future?
from ratel-core.
Related Issues (20)
- Document what happens with superfluous parens HOT 4
- hangs parsing a file with specific unicode character HOT 1
- Paren expression is missing HOT 1
- Error parsing on parameter assignment
- async function HOT 1
- CI build broken due to missing Clippy component HOT 1
- Integrate with full test suites HOT 1
- Nested array access with assignments fail to parse HOT 1
- Use Span to represent source locations
- Failure parsing logical expressions inside for..in
- Consider reorganizing things related to arena HOT 1
- Module struct soundness
- Implement Hash for Expression HOT 2
- Support await expression
- Unable to construct own nodes HOT 4
- Chart about performance HOT 2
- current status of progress
- Support getter/setter syntax
- is this library production ready??
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 ratel-core.