From 1272de61fab6b54d406b9fcae38a9206d2a88392 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 19 Jun 2014 05:16:46 +0000 Subject: [PATCH] CGrammar: Fix preproc conditionals --- PBot/VERSION.pm | 2 +- modules/c2english/CGrammar.pm | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index ff813174..7ee1c18f 100644 --- a/PBot/VERSION.pm +++ b/PBot/VERSION.pm @@ -13,7 +13,7 @@ use warnings; # These are set automatically by the build/commit script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 655, + BUILD_REVISION => 656, BUILD_DATE => "2014-06-18", }; diff --git a/modules/c2english/CGrammar.pm b/modules/c2english/CGrammar.pm index 72a75ebc..fea1cee8 100644 --- a/modules/c2english/CGrammar.pm +++ b/modules/c2english/CGrammar.pm @@ -1,12 +1,10 @@ # C-to-English Grammar # -# Warning: work-in-progress. Many things are incomplete or non-functional. +# Warning: work-in-progress. Some things are incomplete or non-functional. # # todo: # 1. the entire syntax for pointers to functions. # 2. preprocessor directives. (getting there) -# 4. functions to handle the nesting levels (ordinal number generator and CPP stack) -# 6. change returns to prints where appropriate. { my @defined_types = ('`FILE`'); @@ -109,7 +107,7 @@ preproc_conditional: (elif_parts[matchrule => $rule_name])(?) (else_parts[matchrule => $rule_name])(?) { $return .= join('',@{$item[-2]}) . join('',@{$item[-1]}); } - 'endif' + '#' 'endif' { $return .= "End preprocessor conditional.\n"; } if_line: @@ -121,7 +119,7 @@ if_line: { $return .= "If the preprocessor condition^L $item{constant_expression} is true, then ^L"; } elif_parts: - ('elif' constant_expression + ('#' 'elif' constant_expression { $return .= "Otherwise, if the preprocessor condition $item{constant_expression} is true, then ^L"; } ( )[matchrule => $arg{matchrule}](s?) { $return .= join('',@{$item[-1]}); } @@ -129,7 +127,7 @@ elif_parts: { $return = join('', @{$item[-1]}); } else_parts: - 'else' + '#' 'else' { $rule_name = $arg{matchrule}; } ()[matchrule => $arg{matchrule}](s?) { $return = "Otherwise, ^L" . join('',@{$item[-1]}); }