Giter Club home page Giter Club logo

Comments (5)

maciejhirsz avatar maciejhirsz commented on May 18, 2024 2

@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.

maciejhirsz avatar maciejhirsz commented on May 18, 2024 1

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.

matklad avatar matklad commented on May 18, 2024 1

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.

matklad avatar matklad commented on May 18, 2024

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.

TitanNano avatar TitanNano commented on May 18, 2024

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)

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.