-
Notifications
You must be signed in to change notification settings - Fork 630
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
Verilog: create tag of instance's reference name #3469
Comments
Though I don't know well about Verilog, what you have done is interesting. I have worked hard on improving ctags for person like you. Can we say |
I read a document about Verilog quickly.
About
Could you explain the text after
|
Now I understand
|
This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817. This commit does two things: * fill typeref fields of instances with module names, and * extract the module names used for defining instances as defInstance role of module kind. TODO: Update ctags-lang-verilog(7).
See #3470. |
Thanks all of your hard work. I do the changes at a old version of ctags. And don't even notice the usage of reference tag. |
|
Thank you for your proposal.
The output is empty in your report. But it should be: $ ./ctags --fields=+lnrzKZ --extras= -o - test.v
i_a test.v /^ input i_a, i_b;$/;" kind:port line:2 language:Verilog scope:module:test roles:def
i_b test.v /^ input i_a, i_b;$/;" kind:port line:2 language:Verilog scope:module:test roles:def
int1 test.v /^ ref1 int1 ();$/;" kind:instance line:5 language:Verilog scope:module:test roles:def
int2 test.v /^ ref1 int2 ();$/;" kind:instance line:6 language:Verilog scope:module:test roles:def
int3 test.v /^ int3 ();$/;" kind:instance line:9 language:Verilog scope:module:test roles:def
o_c test.v /^ output o_c;$/;" kind:port line:3 language:Verilog scope:module:test roles:def
test test.v /^module test (\/*AUTOARG*\/);$/;" kind:module line:1 language:Verilog roles:def What you are expecting is adding the following 3 lines.
You need them to get:
I did not know about citre at all. (we should add As @masatake san wrote we should use
Proposed by @masatake san; #2703 (comment) I didn't think it was useful, so I haven't implemented it yet. I honestly don't understand yet, but let's implement it. (Oh, you are the contributor of #2703, @my2817.) @masatake san,
No.
No.
The followings are OK.
But the followings are wrong. Either ref1 or ref3 is not module definition.
I'm not sure about the followings:
|
This one is partially based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. Capturing the module names of instances is also proposed in universal-ctags#3469. However, it is not in the scope of this commit.
This one is partially based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. Capturing the module names of instances is also proposed in universal-ctags#3469. However, it is not in the scope of this commit.
I made a pull request only focusing on adding typeref fields. |
This one is partially based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. Capturing the module names of instances is also proposed in universal-ctags#3469. However, it is not in the scope of this commit.
We merged the change based on your proposal. We use typeref field instead of scope field to record the info.
Let's think about 1.
Originally ctags is a tool for tagging definitions. Eventually, we introduced the concept of "reference tags" to Universal Ctags. When I designed "reference tags", I introduced "roles" of the references. Though we introduced the concept "role", it is not used widely in Universal Ctags. I don't have much experience in designing roles. So I think it is not easy.
You can see roles defined in ctags with To make delay the decision, we can choose something generic role names like "used" or "referenced". Designing roles and kinds for a language is one of the most exciting activities in ctags development. Let's enjoy it. |
Extracting reference tags is disabled by default. |
…e tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
…e tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
See #3473. citre has the ability to display reference tags. |
I have tested on #3473. It works well. |
@masatake san, I'm a little bit confused. In Nov. 2020 @my2817 contributed #2703, which provided I've took a look #569 and #680, but not sure how a reference tag looks like? |
This is an incorrect understanding of ctags.
For definition tags, ctags assigns an implicit role called For reference tags, a parser assigns a role to the tag explicitly as I showed #3473. I will repeat the same explanation with targeting C language.
I assumed the relationship between d and x is similar to the relationship between |
@masatake san, Thank you for your explanation. We are getting closer.
I should write this as:
This is my understanding, too.
$ cat foo.c
typedef d double;
struct point {
d x, y;
};
struct point P;
$ ./ctags -o - --sort=no --extras=+r --fields=+rK foo.c
d foo.c /^typedef d double;$/;" typedef typeref:typename:double file: roles:def
point foo.c /^struct point {$/;" struct file: roles:def
x foo.c /^ d x, y;$/;" member struct:point typeref:typename:d file: roles:def
y foo.c /^ d x, y;$/;" member struct:point typeref:typename:d file: roles:def
P foo.c /^struct point P;$/;" variable typeref:struct:point roles:def We implemented the
The new PR, #3473, will emit the following line:
Here And #3473 is equivalent with adding the following lines on the example in C above:
The current C parser does not emit them. I think they are verbose. |
I'm sorry I took a big mistake.
This is wrong. What I should write was:
@hirooih, can I update my comment #3469 (comment) ? |
Oh, I overlooked, too. (VS code was warning me on the line.)
Sure. Here is my fixed version.
Important points are not changed. |
Updated. I found another mistake in the table about the C language input. @hirooih, could you update your original comments if my changes make your comment inconsistent? |
Your fix is rather worse in the following point:
Your fix uses the same kind as the tags for
A client tool has to distinguish:
or
from
or
respectively by using |
Yes.
Yes.
Yes. So I didn't set So a client which does not know about new roles field should not use If a client tool knows about the new roles field, what kind of information ctags can provide for it?
You may be correct. @my2817 wrote:
How can we count them?
We can count "d" but it takes a long time if the tags file is large. If we implement reference tags and --sort is not NO:
This algorithm is O(log(N)). |
Both algorithms are O(N), I think... Am I missing anything? |
Assume See http://ctags.sourceforge.net/tool_support.html. |
upstream-linux.tags is not small. It is about 3GB. I accessed this file with citre/emacs as part of my daily job frequently. The tags is generated with --sort=yes. Assume a situation finding "schedule".
readtags is much faster than grep because readtags uses binary search.
readtags name <<< grep < readtags -l readtags name uses binary search. I wonder whether "schedule" defined in linux is for function, struct or member.
It seems that "schedule" is used frequently as the name for members.
|
Now I understand. I never used readtags (and libreadtags) and don't know its implementation details. So I could not understand at all from your explanation yesterday:-) I have two suggestions.
I cannot stop you from adding the new reference tag to C parser. |
How are they different? |
I see. In the example of manual only followings are reference tags, and there are no reference of variables.
When you implement the reference tag for variables, let's add it on this examples. |
Oh, I see.
In my understanding, your idea is "flat approach";use only kinds to categorize tags. The number of kinds a parser can define is limited: [a-eg-z][A-Z].
Understandable. Designing roles is wild West of ctags. However, I found an obviously useful case. |
Which is "the obviously useful case" in this ticket? BTW after understanding your intention, I have no reason to refuse the PR #3473. If you will add reference tags for C variable types, how will you name the role of them?
In this example defType (or defStruct) is used. From the manual:
How about "declaration tag", the roles field "decl" as its value? #3472 tags a reference to a module. "defInstance" is not a proper name. But I found
|
I will add an explanation about it to docs/*.rst. Please, wait for a while.
This is a question hard to answer.
After reading your comment I wonder where a type is referenced in C language.
Generalizing across languages is impossible. I assume a client tool supporting roles may work in the target language-specific way. Even about kinds, we cannot expect parsers are well consistent. |
I understand this and agree with you. |
I'm not sure. We can increase granularity: None knows how the role should be. So there is no answer. So just |
…e tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
I see. I did not think of it. But this is one of the good choices. |
…e tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
…ce tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
…ce tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
@my2817 We have reimplemented all your ideas in more Universal Ctags way. As the extended game of this issue, I will work on extracting include, and import. |
…ce tags This one is conceptually based on universal-ctags/ctags@master...my2817:ctags:master reported and written by @my2817 at universal-ctags#3469. The test case is also taken from universal-ctags#3469 submitted by @my2817.
I use ctags in my work, with emacs+citre. I write some HACK code to meet my needs. And put the info at here if some others are searching for same solutions.
master...my2817:ctags:master
The name of the parser: verilog
The content of input file:
The tags output you are not satisfied with:
The tags output you expect:
The text was updated successfully, but these errors were encountered: