Comments (6)
There are two separate questions here:
-
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 . -
-
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 thancst-read
.
from eclector.
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.
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.
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.
To clarify, the parse-result protocol has made it into master, but I'm not sure it fully supports this use-case.
from eclector.
I made GrammaTech/sel#11. Let me know if that works for you.
from eclector.
Related Issues (20)
- `#',a -> ECLECTOR.READER:UNQUOTE-IN-INVALID-CONTEXT HOT 7
- QUASIQUOTE can't handle circular lists HOT 1
- Definition of eclector.readtable:readtablep seem to be forgotten
- Error in fixup for standard-object HOT 1
- Issues with #S reader from eclector HOT 8
- Allow recovering from syntax errors when possible
- Invalid ## expression signals an error when *READ-SUPPRESS* is true
- read-from string error with float and *read-base* HOT 1
- Read-delimited-list issue HOT 1
- Handle reading of floating point numbers better HOT 5
- Single quote bug in parse-result HOT 5
- (read-from-string "#c ( #xF #o-1 ) ") not allowed in eclector HOT 2
- Empty escapes are not incorporated into number ID
- Cannot generate the paper PDF. HOT 3
- diagrams in eclector documentation don't fit the page HOT 1
- read-from-string's source don't take into account `:start` HOT 2
- Query: is the source code for the demonstrations from your presentation available? HOT 5
- Tests that print circular structures need to bind *print-circle* nto T
- read-time GENSYM call tests to fail HOT 4
- Package Local Readtables HOT 2
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 eclector.