mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
CGrammar: Fix character-literal and string-literal regexs; add more character-literal constants
This commit is contained in:
parent
d8703faf0e
commit
5c8b845e6d
@ -13,8 +13,8 @@ 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 => 628,
|
BUILD_REVISION => 629,
|
||||||
BUILD_DATE => "2014-06-10",
|
BUILD_DATE => "2014-06-11",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -1346,14 +1346,26 @@ constant:
|
|||||||
$return =~ s/[Uu]$/(unsigned)/;
|
$return =~ s/[Uu]$/(unsigned)/;
|
||||||
$return =~ s/[Ll]$/(long)/;
|
$return =~ s/[Ll]$/(long)/;
|
||||||
}
|
}
|
||||||
| m{'.*?[^\']'} # character constant FIXME: doesn't handle escaped quotes
|
| /(?:\'((?:\\\'|(?!\').)*)\')/ # character constant
|
||||||
{
|
{
|
||||||
my $constant = $item[1];
|
my $constant = $item[1];
|
||||||
|
|
||||||
if($constant eq q/'\n'/) {
|
if($constant eq q('\n')) {
|
||||||
$return = 'a newline';
|
$return = 'a newline';
|
||||||
} elsif($constant eq q/'\t'/) {
|
} elsif($constant eq q('\f')) {
|
||||||
|
$return = 'a form-feed character';
|
||||||
|
} elsif($constant eq q('\t')) {
|
||||||
$return = 'a tab';
|
$return = 'a tab';
|
||||||
|
} elsif($constant eq q('\v')) {
|
||||||
|
$return = 'a vertical tab';
|
||||||
|
} elsif($constant eq q('\b')) {
|
||||||
|
$return = 'an alert character';
|
||||||
|
} elsif($constant eq q('\r')) {
|
||||||
|
$return = 'a carriage-return';
|
||||||
|
} elsif($constant eq q('\b')) {
|
||||||
|
$return = 'a backspace character';
|
||||||
|
} elsif($constant eq q('\'')) {
|
||||||
|
$return = 'a single-quote';
|
||||||
} else {
|
} else {
|
||||||
$return = $constant;
|
$return = $constant;
|
||||||
}
|
}
|
||||||
@ -1369,7 +1381,7 @@ identifier_word:
|
|||||||
{ $return = "`$item[-1]`"; }
|
{ $return = "`$item[-1]`"; }
|
||||||
|
|
||||||
string:
|
string:
|
||||||
/".*?[^\"]"/ # FIXME: doesn't handle escaped quotes
|
/(?:\"(?:\\\"|(?!\").)*\")/
|
||||||
|
|
||||||
reserved:
|
reserved:
|
||||||
'int' | 'double' | 'short' | 'volatile' | 'register' | 'float' | 'signed'
|
'int' | 'double' | 'short' | 'volatile' | 'register' | 'float' | 'signed'
|
||||||
|
Loading…
Reference in New Issue
Block a user