Git Product home page Git Product logo

Comments (6)

kraigher avatar kraigher commented on June 14, 2024

The difficult part is keeping the comments when formatting. For example you could have a comment between 'if' and 'then' so there are a lot of cases to consider. Maybe the solution is to keep the 'if' and 'then' tokens in the AST and associate leading and trailing comments to them. There was support added to associate leading and trailing comments with tokens.

-- leading
if -- trailing

Regarding spacing I should be normalized when formatting the AST anyway so the original spacing is irrelevant. If the original spacing is of interest it can be taken from the positional information if you do not care about tab vs spaces.

from rust_hdl.

m-kru avatar m-kru commented on June 14, 2024

Actually, AST with comments is not an AST anymore, if we want to be accurate. In such case another scenario is to create CST to be used for formatting and language server, and create AST from CST, if someone ever needs pure AST.

from rust_hdl.

kraigher avatar kraigher commented on June 14, 2024

Sure I might have misused the term AST. I have not attached any meaning to the name other than being the data structure for the syntax tree. CST might be a more accurate terminology.

from rust_hdl.

eine avatar eine commented on June 14, 2024

Ref #20 #22

from rust_hdl.

m-kru avatar m-kru commented on June 14, 2024

@kraigher one more remark about indentation when generating VHDL from syntax tree. It looks like right now it is also not easy, as nodes for different blocks (for example for While loop) does not hold information about the SrcPos of whole block. I can see 2 possible solutions. Add SrcPos for such blocks or add elsif|else|end|begin tokens to the syntax tree. What do you think, maybe you have already had better idea?

from rust_hdl.

kraigher avatar kraigher commented on June 14, 2024

Yes those tokens need to be added to the CST to know the position. But as I said in the previous comment they need to added also since they may have leading and trailing comments.

from rust_hdl.

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.