# vim:ts=4:sw=4:expandtab
#
# i3 - an improved dynamic tiling window manager
-# © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+# © 2009 Michael Stapelberg and contributors (see also: LICENSE)
#
# generate-command-parser.pl: script to generate parts of the command parser
# from its specification file parser-specs/commands.spec.
# Cleanup the identifier (if any).
$identifier =~ s/^\s*(\S+)\s*=\s*$/$1/g;
- # Cleanup the tokens (remove whitespace).
- $tokens =~ s/\s*//g;
-
# The default action is to stay in the current state.
$action = $current_state if length($action) == 0;
#say "identifier = *$identifier*, token = *$tokens*, action = *$action*";
for my $token (split(',', $tokens)) {
+ # Cleanup trailing/leading whitespace.
+ $token =~ s/^\s*//g;
+ $token =~ s/\s*$//g;
my $store_token = {
token => $token,
identifier => $identifier,
# Third step: Generate the call function.
open(my $callfh, '>', "GENERATED_${prefix}_call.h");
-my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'Result';
+my $resultname = uc(substr($prefix, 0, 1)) . substr($prefix, 1) . 'ResultIR';
say $callfh "static void GENERATED_call(const int call_identifier, struct $resultname *result) {";
say $callfh ' switch (call_identifier) {';
my $call_id = 0;
say $callfh ' printf("BUG in the parser. state = %d\n", call_identifier);';
say $callfh ' assert(false);';
say $callfh ' }';
-say $callfh ' state = result->next_state;';
say $callfh '}';
close($callfh);