-
Notifications
You must be signed in to change notification settings - Fork 628
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
[systemverilog] parser mistakes typedef for a module's port #2413
Comments
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2413. The original code could not capture "a" in "mod" in the following input because the parser didn't recognize "int32_t" before "a" is a name of type: typedef bit[31:0] int32_t; module mod( input bit clk, input int32_t a ); endmodule This change makes the parser look up the cork symbol table when the parser reads a token with unknown kind. A typedef like int32_t is stored to the symbol table when making a tag for it. As the result, the parser can resolve the kind for the token as typedef when parsing int32_t in "input int32_t a". Signed-off-by: Masatake YAMATO <[email protected]>
Thank you for reporting. |
Thanks a lot for your response! #2492 fixes my original file. Fix is definitely improving things. Where: `include "b.sv"
module mod(
input bit clk,
input int32_t a
);
endmodule b.sv typedef bit[31:0] int32_t; |
@masatake got it, makes sense! I think there is a way to fix this which does not require cross-input file dependencies. module mod(
input dont_need_to_know_what_this_is port_name[64]
); What do your think, would this be implementable? Thanks, |
Obviously Implementable. The original maintainer of the systemverilog parser didn't want to take such algorithm. I'm looking for a new maintainer who implements the algorithm. So as usual, I have to say "pull requests are well come." |
BTW, could you help me about writing a commit log for fixing the SystemVerilog parser? |
@masatake , got it. I just responded to your question on 2489. Thanks, |
@antoinemadec, thank you. One of the difficulties for changing the logic in verilog.c is that the parsers (systemverilog and verilog) parsers use "kind" (verilogKind) as token type like:
kind is a thing assigned to a tag entry in the output. See python.c. It defines types for token like:
Defining types for token brings great flexibility to the parser code. Thank you for trying improving the parser. I'm not good at English. So the ways to express my "thanks" are very limited. Good luck. p.s. #2489, thank you. I'm thinking about organizing , "language consultants". |
An issue with Verilog is that you can have both input name, and input type name, That is, when you parse the word after Let's do as following: let me pick up on a work in progress I have here to extend support to structs. This should help me remember how everything is coded and refresh my C, which has not been used since. I'll then rebase this change over master branch to learn what changed. Finally I'll look into this problem. Cheers, |
Feel free to revert 23297f6 . |
Far from that! Preferably we would even talk a bit about cork, to see if I finally understand it. |
See http://docs.ctags.io/en/latest/internal.html#output-tag-stream about cork. |
SystemVerilog parser and Ada parser, both have the same limitation in their design level. |
|
The algorithm:
The step 2. is based on what @vhda wrote. I guess this doesn't work well because createTag() is called recursively. So the cancellation works partially. |
Hi, SystemVerilog BNF is very complex, so I squashed it. Here is my basic idea.
@masatake san,
I think the current implementation of verilog.c is straight-forward by reading as follows;
Any comments or feedback are welcome. Thank you. |
@hirooih, I would like you to know the typical good parser implementation. In ctags, generally, "kind" is for tags, not for tokens. "kinds" defined in a parser is part of APIs. We should keep their compatibility as much as possible. When writing a token oriented parser, you may want to assign a type to a token like NUMBER, SYMBOL, SEPARATOR, STRING-LITERAL, ... You can define them as you want. They should be used in parser internal. If you change the type definition and/or assignment, the "kinds" definition of parser should not be changed. The types of token and kinds of tags are different things. Users should not know the types of tokens. Actually we don't provide --list-token-types option. A good parser like Python parser uses token types and token keywords.
If a token has TOKEN_KEYWORD type, it can have a subtype called keyword:
These constants are used in the parser internally.
SystemVerilog is one of the parsers that use keywords and kinds mixed-way. I wrote much. HOWEVER, YOU CAN DO AS YOU WANT for fixing the issue. What I would like to know is "kinds" is part of the APIs of the parser. We should try to keep compatibility.
I don't think this is good. Using kind, a user-visible thing in tokens for typing.
Your code reading is correct. However, using kind for tokens is not a good idea. kinds are for tags. |
BTW, if you need explanations for registerEntry() and foreachEntriesInScope() for fixing this issue, please let me know. |
@masatake san I believe I understood what you wrote. I read your similar explanations in #2576, #2618, and this issue. I also think And APIs (
Thank you. I don't think I have to change this part, but I will ask your help if I need. Before I start working, I would like to propose changing
(This is the output of Off course I also update May I do that? |
--sort=no is acceptable. However, I don't think unifying args.ctags is a good idea. You are the only person who improves the SystemVerilog parser on the earth. So If you really need unified args.ctags, you can do that. |
I tried and found you were right. They added only noises.
emits only non-useful messages.
no change
no change |
@antoinemadec, |
Let me close this issue. |
The name of the parser: verilog.c
The command line you used to run ctags:
The content of input file:
foo.sv
The tags output you are not satisfied with:
The tags output you expect:
The version of ctags:
The text was updated successfully, but these errors were encountered: