-
Notifications
You must be signed in to change notification settings - Fork 652
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
Accessing comments through AST #41
Comments
As comments are read and thrown away, you can not access comments through ASTs. |
There is no way to change the implementation of the tokenizer so the comments are not thrown away and can be analyzed in the AST? The reason is that it makes the desired syntax to complex. |
ASTs in the GopherLua are currently just an intermediate-representing format for translating source codes to byte codes. It might be good idea for you to fork the GopherLua and make it what you want. |
I will take a look at it. I might write a tiny purpose built tokenizer for this, as I'm only interested in functions and comments associated with them. However, if you have any pointers on how to implement this is gopher-lua I'm interested. Also, would you be interested in a pull request regarding this? |
If I were you, I would not use ASTs.
lineDefined := fn.Proto.LineDefined
If you implement AST analyze functions and it is not causes significant performance degradation, I would like to consider merging. |
Thanks for the help! That is actally a really neat idea. I think that will work well. Again, thanks for a really nice project. |
Your idea worked perfectly. I wrote a small tokenizer for Lua comments which emitted comments and line number and then used fn.Proto.LineDefined to check if there was a comment associated with the function. |
Good to hear 👍 |
I have a question, how do i get the the LFunction instance to read line number when i exe lua file or lua string. As we register global function as the following: L.SetGlobal("double", L.NewFunction(Double)) /* Original lua_setglobal uses stack... */ |
I would like to annotate Lua code through comments, much like Go to generate documentation. However, I don't see the comments when I call
parse.Dump
.How should I access the comments through the AST?
The text was updated successfully, but these errors were encountered: