Skip to content

Commit

Permalink
optlib2c: reflect --kinds-LANG=- option to kinds definitions directly
Browse files Browse the repository at this point in the history
optlib2c converted --kinds-LANG=- option to invocation of
enableKind function. With this change, optlib2c converts it
to assigning false to `enabled' field of kind definition.

This helps us to hide enableKind from parers.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Dec 25, 2018
1 parent aa9c339 commit fd51425
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
24 changes: 10 additions & 14 deletions misc/optlib2c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ my $options =
unless ($_[0]->{'langdef'} eq $1);
my $refonly = 0;
$refonly = 1 if defined $5;
push @{$_[0]->{'kinddefs'}}, { letter => $2, name => $3, desc => $4,
push @{$_[0]->{'kinddefs'}}, { enabled => 1, letter => $2, name => $3, desc => $4,
refonly => $refonly, roles => [] };
} ],
[ qr/^--_extradef-(.*)=([^,]+),(.+)/, sub {
Expand Down Expand Up @@ -356,7 +356,12 @@ sub extend_table {
sub parse_kinds {
my ($kinds, $opts) = @_;
for (split //, $kinds) {
push @{$opts->{'disabledKinds'}}, $_;
my $letter = $_;
for (@{$opts->{'kinddefs'}}) {
if ($_->{'letter'} eq $letter) {
$_->{'enabled'} = 0;
}
}
}
}

Expand Down Expand Up @@ -443,21 +448,12 @@ EOF

sub emit_initializer {
my $opts = shift;
my $may_unused = (@{$opts->{'disabledKinds'}}) ? "": " CTAGS_ATTR_UNUSED";
my $may_unused = $opts->{'tablenames'} ? "": " CTAGS_ATTR_UNUSED";

print <<EOF;
static void initialize$opts->{'Clangdef'}Parser (const langType language$may_unused)
{
EOF
for (@{$opts->{'disabledKinds'}}) {
print <<EOF;
{
kindDefinition *kdef = getLanguageKindForLetter (language, '$_');
enableKind (kdef, false);
}
EOF
}

if ($opts->{'tablenames'}) {
print "\n";

Expand Down Expand Up @@ -551,11 +547,12 @@ sub emit_kinddefs {
static kindDefinition $opts->{'Clangdef'}KindTable [] = {
EOF
for (@{$opts->{'kinddefs'}}) {
my $enabled = $_->{"enabled"}? "true": "false";
print <<EOF;
{
EOF
print <<EOF;
true, \'$_->{'letter'}\', "$_->{'name'}", "$_->{'desc'}",
$enabled, \'$_->{'letter'}\', "$_->{'name'}", "$_->{'desc'}",
EOF
if ($_->{'refonly'}) {
print <<EOF;
Expand Down Expand Up @@ -818,7 +815,6 @@ sub main {
patterns => [],
extensions => [],
aliases => [],
disabledKinds => [],
regexs => [# { regex => "", name => "", kind => "", flags => "", mline => 1|0 },
],
kinddefs => [# { letter => '', name => "", desc => "" },
Expand Down
2 changes: 1 addition & 1 deletion optlib/cmake.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "xtag.h"


static void initializeCMakeParser (const langType language CTAGS_ATTR_UNUSED)
static void initializeCMakeParser (const langType language)
{

addLanguageRegexTable (language, "main");
Expand Down
14 changes: 3 additions & 11 deletions optlib/gdbinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,8 @@
#include "xtag.h"


static void initializeGdbinitParser (const langType language)
static void initializeGdbinitParser (const langType language CTAGS_ATTR_UNUSED)
{
{
kindDefinition *kdef = getLanguageKindForLetter (language, 'D');
enableKind (kdef, false);
}
{
kindDefinition *kdef = getLanguageKindForLetter (language, 'l');
enableKind (kdef, false);
}
}

extern parserDefinition* GdbinitParser (void)
Expand All @@ -41,13 +33,13 @@ extern parserDefinition* GdbinitParser (void)
true, 'd', "definition", "definitions",
},
{
true, 'D', "document", "documents",
false, 'D', "document", "documents",
},
{
true, 't', "toplevelVariable", "toplevel variables",
},
{
true, 'l', "localVariable", "local variables",
false, 'l', "localVariable", "local variables",
},
};
static tagRegexTable GdbinitTagRegexTable [] = {
Expand Down
2 changes: 1 addition & 1 deletion optlib/markdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "xtag.h"


static void initializeMarkdownParser (const langType language CTAGS_ATTR_UNUSED)
static void initializeMarkdownParser (const langType language)
{

addLanguageRegexTable (language, "main");
Expand Down
2 changes: 1 addition & 1 deletion optlib/puppetManifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "xtag.h"


static void initializePuppetManifestParser (const langType language CTAGS_ATTR_UNUSED)
static void initializePuppetManifestParser (const langType language)
{

addLanguageRegexTable (language, "main");
Expand Down

0 comments on commit fd51425

Please sign in to comment.