generate-command-parser: Add '#pragma once'

This commit is contained in:
Orestis Floros 2020-04-20 04:14:26 +02:00
parent 2954125324
commit af7c4ae76b
No known key found for this signature in database
GPG Key ID: A09DBD7D3222C1C3
1 changed files with 3 additions and 0 deletions

View File

@ -117,6 +117,7 @@ my @keys = sort { (length($b) <=> length($a)) or ($a cmp $b) } keys %states;
open(my $enumfh, '>', "GENERATED_${prefix}_enums.h"); open(my $enumfh, '>', "GENERATED_${prefix}_enums.h");
my %statenum; my %statenum;
say $enumfh '#pragma once';
say $enumfh 'typedef enum {'; say $enumfh 'typedef enum {';
my $cnt = 0; my $cnt = 0;
for my $state (@keys, '__CALL') { for my $state (@keys, '__CALL') {
@ -131,6 +132,7 @@ close($enumfh);
# Third step: Generate the call function. # Third step: Generate the call function.
open(my $callfh, '>', "GENERATED_${prefix}_call.h"); open(my $callfh, '>', "GENERATED_${prefix}_call.h");
my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR'; my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR';
say $callfh '#pragma once';
say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {"; say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {";
say $callfh ' switch (call_identifier) {'; say $callfh ' switch (call_identifier) {';
my $call_id = 0; my $call_id = 0;
@ -206,6 +208,7 @@ close($callfh);
# Fourth step: Generate the token datastructures. # Fourth step: Generate the token datastructures.
open(my $tokfh, '>', "GENERATED_${prefix}_tokens.h"); open(my $tokfh, '>', "GENERATED_${prefix}_tokens.h");
say $tokfh '#pragma once';
for my $state (@keys) { for my $state (@keys) {
my $tokens = $states{$state}; my $tokens = $states{$state};