Merge pull request #3079 from orestisf1993/generate-command-parser

generate-command-parser.pl: remove trailing characters
This commit is contained in:
Ingo Bürk 2017-12-12 16:49:48 +01:00 committed by GitHub
commit 36449ba22d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -116,17 +116,16 @@ my @keys = sort { (length($b) <=> length($a)) or ($a cmp $b) } keys %states;
open(my $enumfh, '>', "GENERATED_${prefix}_enums.h");
# XXX: we might want to have a way to do this without a trailing comma, but gcc
# seems to eat it.
my %statenum;
say $enumfh 'typedef enum {';
my $cnt = 0;
for my $state (@keys, '__CALL') {
say $enumfh " $state = $cnt,";
say $enumfh ',' if $cnt > 0;
print $enumfh " $state = $cnt";
$statenum{$state} = $cnt;
$cnt++;
}
say $enumfh '} cmdp_state;';
say $enumfh "\n} cmdp_state;";
close($enumfh);
# Third step: Generate the call function.
@ -225,7 +224,7 @@ for my $state (@keys) {
$next_state = '__CALL';
}
my $identifier = $token->{identifier};
say $tokfh qq| { "$token_name", "$identifier", $next_state, { $call_identifier } }, |;
say $tokfh qq| { "$token_name", "$identifier", $next_state, { $call_identifier } },|;
}
say $tokfh '};';
}