Code Monkey home page Code Monkey logo

Comments (5)

mds1 avatar mds1 commented on August 24, 2024 1

Yea happy to take a shot! And any guidance/tips on where to implement/test would be great, as I’m not yet too familiar with the codebase :)

from bulloak.

mds1 avatar mds1 commented on August 24, 2024 1

Thanks for all the details! It definitely is more involved than I thought so I probably won't have the time to implement it anytime soon, and would happily defer the work to you if you have the bandwidth πŸ˜…

From a UX standpoint, I think the recursive parsing option is better than requiring a new keyword in tree files

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Cool! This sounds like a good use case πŸ‘πŸ» I'm happy to implement it.

If you'd like to give it a go lmk first, and I'll ping you after I merge a big revamp for bulloak check I'm working on.

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Okay, sorry for the delay, I finally have a structure that I'm happy with for bulloak check, so I can share some pointers with you. I haven't merged it because I need to finish implementing the rules, add docs & more tests, but you can take a look at #31 if you want to start getting a hang of the new repo.

After thinking a bit more about this feature, I realized this is a non-trivial amount of work. However, the steps are roughly as follows:

  • Take a look at the _parse function (arguably the obscurest part of the code because it's recursive),
    fn _parse(&self) -> Result<Ast> {
    specifically at the TokenKind::It branch
    TokenKind::It => {
    let title = self.parse_string(next_token);
    let previous = self.previous().unwrap();
    Ok(Ast::Action(Action {
    title,
    span: Span::new(current_token.span.start, previous.span.end),
    }))
    }
    • One solution is to _parse recursively until it finds something that isn't a TokenKind::Word.
    • Another is to add a new keyword which we remove further down the compiler so that it doesn't show up in the comments.
    • Note that this should track the indentation level, unsure how this might look, but my first thought is to use a stack and add the current level to the ast::Ast variant created in the next bullet.
  • Then, you can add a new ast::Ast variant -- something like ActionDetail or ActionDescription.
  • Then, you can extend ast::Action to include a children: Vec<Ast> and the compiler should guide you into filling all the gaps introduced, which should roughly be:
    • Add a corresponding visit_action_detail function to the syntax::visitor::Visitor trait. This will also break the project in a few places (semantics, modifiers & translator).
    • Map all of the child ActionDetail of an action into the lexeme field of hir::Comment in hir::translator.
  • Then (or before), test it all out, make sure we don't create the new AST nodes when we shouldn't and add documentation.

It's quite a lot of work, so feel free to leave it to me. Also, the parsing step is a bit overcomplicated because it was more natural for me to do it recursively, but it should probably be done iteratively. If you decide to dive in, lmk if you have any questions!

Also, it's probably best if you wait a bit to give me time to finish #31.

from bulloak.

alexfertel avatar alexfertel commented on August 24, 2024

Thanks for all the details! It definitely is more involved than I thought so I probably won't have the time to implement it anytime soon, and would happily defer the work to you if you have the bandwidth πŸ˜…

Ofc! No worries. I'll get to it when I can!

from bulloak.

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.