-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Inconsistant NodeType.simpleName() #8540
Comments
@andrewstein it appears that simpleName is long dead code which was only added for SexpMaker (which no longer calls it). It is isolated enough that I will remove this method for JRuby 10 (we generally do not consider org.jruby.ast to be a public API space -- although if you have a need then let me know). |
Thank you @enebo for your reply. My goal is to dump the AST out to a file. I cannot use the
|
@andrewstein This may not help you since you are probably using Java only but we have bin/ast which does print out the AST but it is a mixture or Ruby and Java. It also probably does not print what you are looking for (it is largely something for us to see structure). You can look with I will also point out JRuby 10 will work with both the legacy parser (which you are looking at) and the prism parser (a cross-Ruby-implementation) which effectively is a foreign function callout to a C library which produces a blob we can turn into an AST. The AST it makes is not the same as the legacy one. That parser is fairly well documented though and it can also do syntax-level AST info. We do have some experimental bindings to call it through Chicory using web assembly so there is a pure-Java path...just not completed yet. That is a lot of digest but I am not sure how long and for what you need this . |
@andrewstein you can pop onto our matrix channel to chat too if you want: https://app.element.io/?updated=1.11.69#/room/#jruby:matrix.org |
Thank you @enebo I will have to look into all of this in two weeks time. Happy holidays :-) |
Environment Information
Provide at least:
Expected and Actual Behaviors
A call to
node.getNodeType().simpleName()
should be consistent. For nodes of classBlockNode
it returns "block" which is fine. However, nodes of classRestArgNode
it return "res".Looking at the implementation, it would seem that it strips the last four chars of the lower case of the enum
NodeType
.Most
NodeType
s end with "NODE", in our exampleBLOCKNODE
. However, a couple ofNodeType
s end with "ARG", in our exampleRESTARG
, which leads to the truncated "res". (There is also a NodeType that ends with "VALUE" :-) ).This can be fixed by adding "NODE" to all
NodeType
s or by adding special handling insimpleName()
of the few inconsistentNodeType
s.The text was updated successfully, but these errors were encountered: