-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature requiring: Adding source mapping information during macro expansion. #900
Comments
Just a few questions to help interpret the question.
Why do you need this information during expansion?
If so, that seems a more approachable question. To reveal binding information for a program written in Chez Scheme you need to run the expander. If Chez Scheme could output a "source map" that would help you in implementing "goto-definition". Note: If you want "goto-definition" to work while the program is "broken" (i.e. can't be expanded due to |
Scheme-langserver now has "goto-definition", but it can't work for self-defined macros which may introduce new identifiers during expansion. And this is why I put above example.
As my understanding, your suggestion is to build a chain like macro callee-> pattern -> template -> expansion. And the last step compounds complex comparison and tree traverse. I call them "source mapping information" and I truely did this. I issue this feature mainly because of the efficiency problem. Nested macros usually cause undecidable(if I use this word correctly) time-consuming, because "goto-definition" requiring an abstract interpreter evaluates all expansions and backwarding identifier claiments from expansion to macro callee , which interleaves macro expanding. I can't say, oh, my code didn't work buggy. But I can say, directly give me source mapping information may helped a lot. |
No I am suggesting that you feed the entire file (module) into the expander and get a fully expanded module back. |
I'm not sure, do you means: > (expand '(try c (except c [else c])))
((#2%call/1cc
(lambda (#{escape lge2hkfkseab2xecwg4knq562-5})
(#2%with-exception-handler
(lambda (#{c lge2hkfkseab2xecwg4knq562-6})
(let ([#{c lge2hkfkseab2xecwg4knq562-7} #{c lge2hkfkseab2xecwg4knq562-6}])
(#{escape lge2hkfkseab2xecwg4knq562-5}
(lambda () #{c lge2hkfkseab2xecwg4knq562-7}))))
(lambda ()
(#2%call-with-values
(lambda () c)
(lambda #{args lge2hkfkseab2xecwg4knq562-8}
(#{escape lge2hkfkseab2xecwg4knq562-5}
(lambda ()
(#2%apply
#2%values
#{args lge2hkfkseab2xecwg4knq562-8})))))))))) How could I know the |
Note: I know the specifics for Racket, but only the general workings of Chez Scheme,
Your example was (with indices added):
Now you want to know something about c_2. However, in your example you are handing So the first task is to add source locations to the input. Use annotations to add source locations: |
No, you don't understand what I mean. (expand '(try c_0 (except c_1 [else c_2]))) I want to know c_1 claims an identifier, and c_2 call it. And, I can only know this by recognizing In above process, annotation works nothing. |
I see that as step 2. In the source code both c_1 and c_2 are just "c". So the first step must be to find out what In step 2 you want to examine the binding information in the fully expanded module. In the worst case, you can make a recursive descent of the fully expanded module |
Hey, I don't know whether I talk this feature in Chez's tongue, but scheme-langserver really wants source mapping information during expansion. Here, source mapping information I mean is: after macro expansion, the result expression, its all elements could be addressed their correspondence with the origin s-expression before expansion.
An example may help understanding. In following code:
many programmers want to know the
c
in handling branch is relating to thec
exception afterexcept
. It's called "goto-definition" in LSP(Language Server Protocol). You may find the definition oftry-except
macro in the end of this post, apparently it requires analysis on addressing correspondence between symbols before and after expansion.And here I want to talk more about my detail requirements:
syntax-rules
andsyntax-case
, I built a chain from pattern to template to expansion by pure matching method, and apparently, it works buggy and slowly.s/syntax.ss
, or refer racket7. It occurs to me whether Chez Scheme's community could help.Above is a requirement, not an order or some rude things. If community could help, scheme-langserver and maybe many programmers would be helped. If not, we still gratefully thank you for your work.
Happy new year.
try... except
macro and macro expansionThe
try ... except
macro is usually defined as following:And the expansion of first code, is usually like following:
The text was updated successfully, but these errors were encountered: