Skip to content
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

Support Null Tag #4151

Closed
hirooih opened this issue Dec 7, 2024 · 8 comments
Closed

Support Null Tag #4151

hirooih opened this issue Dec 7, 2024 · 8 comments
Assignees
Milestone

Comments

@hirooih
Copy link
Contributor

hirooih commented Dec 7, 2024

Some languages (ex. (System)Verilog #4129) supports a Null Tag (a tag whose name field is "\0").
The current makeTagEntry() ignores or warns it.

@hirooih
Copy link
Contributor Author

hirooih commented Dec 8, 2024

Here is my comment to #4129 (comment)

Could you open a separate issue to support a null tag?

I've opened this issue.

I have two concerns:

  1. The current implementation of libreadtags skips lines with empty names.
    ...
    The line comparing with '\0' comes from the exuberant ctags.
    Our ancestors assume an empty tag is invalid.

I don't concerns this. The u-ctags has many more features than the exuberant ctags. Emiting more tags is not an issue. As you wrote, it just ignores a Null Tag.

I rather fear that other client tools may crash with null tags. So we may need a command line option to disable Null Tags.

  1. the other file formats
    u-ctags supports etags and xref. Do they consider null tags?

As far as I read Xref output man page it can express a Null Tag.


Again as I wrote on #4129 (comment)

Even if it were not currently supported, it would not be worth the bother to support it, I think.

This is my position.

@masatake masatake self-assigned this Dec 8, 2024
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 8, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
@cousteaulecommandant
Copy link
Contributor

I've written a few examples in JSON, Tcl, and SystemVerilog featuring null tags, in case you're interested.

Interestingly, tags that are inside a "namespace" that has a null identifier are displayed in the hierarchy as such, even if the identifier won't.
For example, this JSON code:

{"": {"": {"a": {"": {"": {"b": {"": {"": {"c": 0}}}}}}}}}

outputs

a	[...]	o
b	[...]	o	object:a..
c	[...]	n	object:a...b..

(the leading blank containers are ignored, but the intermediate ones are preserved - note that it says c is in a...b.. and not a.b)

(Attached: null-tags.r.tar.gz)

@jafl
Copy link
Contributor

jafl commented Dec 10, 2024

Please make a PR for the tests that you attached.

@masatake masatake added this to the 6.2 milestone Dec 11, 2024
@cousteaulecommandant
Copy link
Contributor

cousteaulecommandant commented Dec 13, 2024

Please make a PR for the tests that you attached.

I can do that but it'll cause CI tests to fail ("unexpected exit state"), so I first need to figure out how to exclude those tests from CI.
I'll put something together.

masatake added a commit to masatake/ctags that referenced this issue Dec 13, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating ctags(1),
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"
- update units.py supporting nulltags

Signed-off-by: Masatake YAMATO <[email protected]>
@masatake
Copy link
Member

@cousteaulecommandant You can ignore failures.

What we need are pairs of input and expected output.
null-tags.r.tar.gz is not suitable for my git workflow.

Thank you so much for your attention and participation.

masatake added a commit to masatake/ctags that referenced this issue Dec 14, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
@cousteaulecommandant
Copy link
Contributor

Should I modify expected.tags manually to reflect what I expect, including empty tags? Or just use what ctags outputs?

@masatake
Copy link
Member

Yes, please modify expected.tags manually to reflect what you expect.

masatake added a commit to masatake/ctags that referenced this issue Dec 14, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
masatake added a commit to masatake/ctags that referenced this issue Dec 14, 2024
Close universal-ctags#4151.

Consider a parser attempting to emit a null tag, a tag whose
name is the empty string '\0'.

Original Behavior:

    It warns "ignoring null tag..." if both parserDefinition::allowNullTag and
    tagEntryInfo::allowNullTag are unset.

    It does not warn if either parserDefinition::allowNullTag or
    tagEntryInfo::allowNullTag is set.

    It does not emit the null tag, even if allowNullTag is set.

With This Change: The code now emits the null tag if:

    Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag
    is set, and

    The --extras=+0 (or --extras=+{nulltag}) option is specified.

TODO:
- versioning
- updating the hacking guide
- make readtags warn "unsupported" if it finds "!_TAG_FIELD_DESCRIPTION"

Signed-off-by: Masatake YAMATO <[email protected]>
@cousteaulecommandant
Copy link
Contributor

OK done, see #4157 :)
I have noticed that the Tcl parser doesn't seem to handle quoted/braced proc names, so neither proc {} {} {} nor proc "" {} {} will work (and neither does proc {foo} {} {} nor proc "bar" {} {} anyway), so maybe I should get rid of the Tcl test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants