3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-23 19:22:40 +01:00

CGrammar: Fix /* comment */ regex, minor improvement to while loop, need to fix arrays

This commit is contained in:
Pragmatic Software 2014-06-11 08:29:58 +00:00
parent 5c8b845e6d
commit 992dae043f
2 changed files with 14 additions and 9 deletions

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 629, BUILD_REVISION => 630,
BUILD_DATE => "2014-06-11", BUILD_DATE => "2014-06-11",
}; };

View File

@ -296,14 +296,19 @@ iteration_statement:
{ {
if($item{expression} =~ /(^\d+$)/) { if($item{expression} =~ /(^\d+$)/) {
if($1 == 0) { if($1 == 0) {
$item{expression} = 'never'; $return = "Never ^L";
} else { } else {
$item{expression} = 'forever'; $return = "Repeatedly ^L";
} }
} else {
$return = "While $item{expression}, ^L";
} }
$return = "While $item{expression}, ^L"; if($item{statement}) {
$return .= $item{statement} . "\n"; $return .= $item{statement} . "\n";
} else {
$return .= "do nothing.\n";
}
} }
| 'do' statement[context => 'do loop'] 'while' '(' expression ')' ';' | 'do' statement[context => 'do loop'] 'while' '(' expression ')' ';'
{ $return = "Do the following:^L $item{statement}\nDo this as long as $item{expression}.\n"; } { $return = "Do the following:^L $item{statement}\nDo this as long as $item{expression}.\n"; }
@ -987,7 +992,7 @@ direct_declarator:
identifier[context => 'direct_declarator'] array_declarator(s?) identifier[context => 'direct_declarator'] array_declarator(s?)
{ {
if(@{$item{'array_declarator(s?)'}}) { if(@{$item{'array_declarator(s?)'}}) {
$return = join('', @{$item{'array_declarator(s?)'}}) . "$item{identifier}"; $return = "$item{identifier}|" . join('', @{$item{'array_declarator(s?)'}});
} else { } else {
$return = "$item{identifier}"; $return = "$item{identifier}";
} }
@ -1002,10 +1007,10 @@ direct_declarator:
$prefix .= ' '; $prefix .= ' ';
} }
$return = $prefix . join('', @{$item{'array_declarator(s)'}}) . $name; $return = "$name|$prefix" . join('', @{$item{'array_declarator(s)'}});
} }
| '(' declarator array_declarator(s) ')' | '(' declarator array_declarator(s) ')'
{ $return = join('', @{$item{'array_declarator(s)'}}) . $item{'declarator'}; } { $return = $item{'declarator'} . join('', @{$item{'array_declarator(s)'}}) }
| '(' declarator ')' | '(' declarator ')'
{ $return = $item{declarator}; } { $return = $item{declarator}; }
@ -1303,7 +1308,7 @@ comment:
{ $return = $item{comment_cxx}; } { $return = $item{comment_cxx}; }
comment_c: comment_c:
m{/\*(.*?)\*/}s m{/\*[^*]*\*+([^/*][^*]*\*+)*/}s
{ {
$return = $item[1]; $return = $item[1];
$return =~ s|^/\*+\s*||; $return =~ s|^/\*+\s*||;