3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 22:09:26 +01:00

CGrammar: Add offsetof

This commit is contained in:
Pragmatic Software 2014-08-10 05:03:37 +00:00
parent 48382de916
commit 527e8490a3
2 changed files with 8 additions and 3 deletions

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 770,
BUILD_DATE => "2014-08-05",
BUILD_REVISION => 771,
BUILD_DATE => "2014-08-09",
};
1;

View File

@ -628,6 +628,7 @@ logical_OR_AND_expression:
and $expression =~ / /
and $expression !~ /^the .*? number \S+$/i
and $expression !~ /the size of/i
and $expression !~ /the offset/i
and $expression !~ /^the result of the/) {
$return = 'the result of the expression ^L';
}
@ -1037,6 +1038,10 @@ unary_expression:
}
| Alignof '(' type_name ')'
{ $return = "the alignment of the type $item{type_name}"; }
| 'offsetof' '(' type_name[context => 'offsetof'] ',' identifier ')'
{
$return = "the offset, in bytes, of member $item{identifier} from the beginning of $item{type_name}";
}
Alignof:
'_Alignof'
@ -1925,5 +1930,5 @@ reserved:
/(auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto
|if|inline|int|long|register|restrict|return|short|signed|sizeof|static|struct|switch|typedef
|union|unsigned|void|volatile|while|_Alignas|alignas|_Alignof|alignof|_Atomic|_Bool|_Complex|_Generic
|_Imaginary|_Noreturn|noreturn|_Static_assert|static_assert|_Thread_local)\b/x
|_Imaginary|_Noreturn|noreturn|_Static_assert|static_assert|_Thread_local|offsetof)\b/x