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
Add ADA ctags parser #3166
Add ADA ctags parser #3166
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems alright but I also don't know ada at all.
From quicky looking over the wikipedia article, Ada seems to offer a great many ways to declare types (and even subtypes). I haven't seen this in the test files. I hope the parser copes with them.
Its literally, erm ... decades since I did any Ada, and I am not sure how much the language may have changed since then, but IIRC it doesn't have any more complex types than any other modern OO language, C++, Go, Rust etc but it does allow lots of constraints on them. But constraints are not of interest to ctags so (from a quick squiz at ada.c) they are simply skipped. Same with renames etc. So the actual parser "copes" by ignoring. 😄 Only composite type definitions need their contents parsing. The underlying Ada syntax is far more consistent than C/C++ so extracting the parts of interest is simpler than for those languages so I am not surprised the parser is simpler than the new C++ parser. That said @kugel- is probably right that the tests don't cover all the options, but Ada users can always PR more tests upstream. |
Yeah, quite possibly and this is really the impression I got when looking at the examples. But at the same time I just gave up studying it in greater detail because this isn't something one ever wants to learn ;-). |
Well, using the wikipedia article as a reference you will notice that the syntax is basically Similarly functions and procedures are just It can all be parsed from the keywords, Ada is not a context sensitive language. |
@elextr Syntax is fine, it's very Pascal-like and not very hard to parse I think. But it's all those language features like "subprograms", "subtasks", "subprogram specifications" etc. which make the language crazy. I mapped them to the TM types somehow but I don't claim it is right. But this can be improved when some real ADA users start complaining. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have run out of time to look at the mapping of the more esoteric Ada tag types, need to RTFC to see what they actually mean.
{'p', tm_tag_package_t}, // package | ||
{'T', tm_tag_typedef_t}, // typespec | ||
{'t', tm_tag_typedef_t}, // type | ||
{'U', tm_tag_undef_t}, // subspec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both U
and u
are just another way of defining a type, I would have made them typedef
{'l', tm_tag_enumerator_t}, // literal | ||
{'V', tm_tag_variable_t}, // varspec | ||
{'v', tm_tag_variable_t}, // variable | ||
{'f', tm_tag_undef_t}, // formal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its time tagmanager got to know more kinds, the z
kind (template parameter) in the new cxx parser is also mapped to undefined. Would be good if parameter names and generic/template parameters were available to autocomplete, although that then needs scope to avoid overloading the autocompletes. But the use of folds as an initial scope as Geany does for the status bar scope would be a good start.
src/tagmanager/tm_parser.c
Outdated
{'f', tm_tag_undef_t}, // formal | ||
{'n', tm_tag_macro_t}, // constant | ||
{'x', tm_tag_undef_t}, // exception | ||
{'R', tm_tag_function_t}, // subprogspec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have mapped this to tm_tag_prototype_t
, thats effectively what it is.
src/tagmanager/tm_parser.c
Outdated
{'x', tm_tag_undef_t}, // exception | ||
{'R', tm_tag_function_t}, // subprogspec | ||
{'r', tm_tag_function_t}, // subprogram | ||
{'K', tm_tag_method_t}, // taskspec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a task is called a "method" (which is fine its a function running in a new thread) then a taskspec is probably a prototype maybe (unsure sounding tone of voice).
@techee agree, my last two posts were aimed at addressing @kugel- concern "I hope the parser copes with them" and the list of c tags kinds at line 120 indeed suggests that it copes ... by recognising them. Agree the mapping is difficult, my partial contribution in review comments. As I ranted in one of them, time tagmanager learned some more tag types and static scope limits (and no I'm not offering to do it ;-). |
Thanks, will have a look at them.
Agree. Maybe simply some more of |
@elextr I did more or less what you suggested but no matter how I tried (and with ADA no guarantees I "tried correctly") I could't get the 'U' and 'V' tags generated so I disabled them. I also added unit tests for those kinds that were missing. |
How do I tell if I'm getting those tags? |
I'm not sure what a typespec (as distinct from a type) is meant to be, its not an Ada language thing really. The code in ada.c seems to consider something like |
Best to use universal-ctags directly - we now have the same parsers.
My guess was those were from the |
Ok, thats what I did, using uctags current git, I just thought you might have some debugging magic.
Yes, |
Oh, and one more thing, you should add |
Is there anything left to be done here? |
Not that I can tell, the U and V tags seem not to be generated, so it doesn't matter what they map to. Otherwise IIRC it was ok. |
No description provided.