GithubHelp home page GithubHelp logo

Comments (6)

scymtym avatar scymtym commented on June 12, 2024

There are two separate questions here:

  1. Can't we ensure that every CST node has an associate source range?

    For eclector.concrete-syntax-tree:cst-read we take the position that not all CST nodes have a corresponding source range.

    • One reason are reader macros which can fabricate arbitrary expressions not related to the source at all. The symbol quote in (quote 1 2 3 4) is a simple example of this.

    • Another reason are parts of the list structure that have no representation in the input string:

      (labels ((maptree (fn tree)
                 (if (concrete-syntax-tree:consp tree)
                     (list
                      (funcall fn tree) ; CHANGED
                      (maptree fn (concrete-syntax-tree:first tree))
                      (maptree fn (concrete-syntax-tree:rest tree)))
                     (funcall fn tree))))
        (maptree #'concrete-syntax-tree:source
                 (with-input-from-string (in "'(1 2 3 4)")
                   (eclector.concrete-syntax-tree:cst-read in))))
      ((0 . 10) NIL (NIL ((1 . 10) (2 . 3) (NIL (4 . 5) (NIL (6 . 7) (NIL (8 . 9) NIL)))) NIL))

    A custom client can of course implement a different behavior. To this end, consider the wip-parse-result-protocol-2 branch and in particular https://github.com/robert-strandh/Eclector/blob/wip-parse-result-protocol-2/code/parse-result/second-climacs-test.lisp .

  2. Is there a better way to integrate skipped input into the parse result?

    Again, consider the wip-parse-result-protocol-2 branch and in particular https://github.com/robert-strandh/Eclector/blob/wip-parse-result-protocol-2/code/parse-result/second-climacs-test.lisp .

    There is a good chance we will do something very similar in the master branch to better support clients other than cst-read.

from eclector.

eschulte avatar eschulte commented on June 12, 2024

Thank you for the pointer to that branch. I hope this functionality makes its way into master. Using the branch and adopting the example you cited, I was able to get exactly what I wanted (a tree structure with sufficient information to fully reproduce the full text of the source file) with a much simpler implementation. See https://github.com/GrammaTech/sel/blob/wip-lisp-diff-uses-eclector-parse-result-protocol-2/ast-diff/lisp-diff.lisp

from eclector.

eschulte avatar eschulte commented on June 12, 2024

To followup, over a year later we're still using this branch. Any chance this functionality will (or maybe has already) make its way to master?

from eclector.

scymtym avatar scymtym commented on June 12, 2024

Any chance this functionality will (or maybe has already) make its way to master?

This has not happened yet, but several steps towards that goal are underway.

from eclector.

scymtym avatar scymtym commented on June 12, 2024

To clarify, the parse-result protocol has made it into master, but I'm not sure it fully supports this use-case.

from eclector.

scymtym avatar scymtym commented on June 12, 2024

I made GrammaTech/sel#11. Let me know if that works for you.

from eclector.

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.