From a501557d359a620d00c544fdbc8713408f1977e4 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 20 Jun 2014 09:12:56 +0000 Subject: [PATCH] CGrammar: Support long long suffix on constants; add .0 to floating pointer constants when omitted --- PBot/VERSION.pm | 2 +- modules/c2english/CGrammar.pm | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/PBot/VERSION.pm b/PBot/VERSION.pm index c32f5a4b..178d2b4e 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 => 659, + BUILD_REVISION => 660, BUILD_DATE => "2014-06-20", }; diff --git a/modules/c2english/CGrammar.pm b/modules/c2english/CGrammar.pm index a810ddca..3ad5e98c 100644 --- a/modules/c2english/CGrammar.pm +++ b/modules/c2english/CGrammar.pm @@ -1382,24 +1382,25 @@ constant: } else { $return = $item[1]; } + $return .= '0' if $return =~ /\.$/; } - | /0x[0-9a-f]+[lu]{0,2}/i + | /0x[0-9a-f]+[lu]{0,3}/i { $return .= 'unsigned ' if $item[1] =~ s/[Uu]//; - $return .= 'long ' if $item[1] =~ s/[Ll]//; + $return .= 'long ' while $item[1] =~ s/[Ll]//; $return = "the $return" . "hexadecimal number $item[1]"; } - | /0\d+[lu]{0,2}/i + | /0\d+[lu]{0,3}/i { $return .= 'unsigned ' if $item[1] =~ s/[Uu]//; - $return .= 'long ' if $item[1] =~ s/[Ll]//; + $return .= 'long ' while $item[1] =~ s/[Ll]//; $return = "the $return" . "octal number $item[1]"; } - |/-?[0-9]+[lu]{0,2}/i # integer constant + | /-?[0-9]+[lu]{0,3}/i # integer constant { - $return = $item[-1]; - $return = "long $return" if $return =~ s/[Ll]//; - $return = "unsigned $return" if $return =~ s/[Uu]//; + $return .= "unsigned " if $item[-1] =~ s/[Uu]//; + $return .= "long " while $item[-1] =~ s/[Ll]//; + $return .= $item[-1]; } | /(?:\'((?:\\\'|(?!\').)*)\')/ # character constant {