summaryrefslogtreecommitdiff
path: root/source4/pidl/idl.yp
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-12-25 14:59:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:47:43 -0500
commita4fe56c06a95bf5278a4a0efdd976febc2b9866b (patch)
treee182f8bf0dc1842298f5bb714192bc6177044416 /source4/pidl/idl.yp
parent8e924678b205910a5147ceb948d4db86e3a9ae0c (diff)
downloadsamba-a4fe56c06a95bf5278a4a0efdd976febc2b9866b.tar.gz
samba-a4fe56c06a95bf5278a4a0efdd976febc2b9866b.tar.bz2
samba-a4fe56c06a95bf5278a4a0efdd976febc2b9866b.zip
r12481: Move parser-specific utility functions to idl.yp, remove some unused functions
Allow the use of non-typedef structs and unions when declaring variables. Allow the use of the 'signed' and 'unsigned' qualifiers for integer types (This used to be commit bc6b45e242c8d7b2ef1a6e6d3eb172c27afd952d)
Diffstat (limited to 'source4/pidl/idl.yp')
-rw-r--r--source4/pidl/idl.yp59
1 files changed, 44 insertions, 15 deletions
diff --git a/source4/pidl/idl.yp b/source4/pidl/idl.yp
index 430f7e1b06..62f636cb00 100644
--- a/source4/pidl/idl.yp
+++ b/source4/pidl/idl.yp
@@ -140,15 +140,22 @@ usertype: struct | union | enum | bitmap;
typedecl: usertype ';' { $_[1] };
-type: usertype | identifier
- | void { "void" }
+sign: 'signed' | 'unsigned';
+
+existingtype:
+ | sign identifier { "$_[1] $_[2]" }
+ | identifier
;
-enum: 'enum' optional_identifier '{' enum_elements '}'
+type: usertype | existingtype | void { "void" } ;
+
+enum_body: '{' enum_elements '}' { $_[2] };
+opt_enum_body: | enum_body;
+enum: 'enum' optional_identifier opt_enum_body
{{
"TYPE" => "ENUM",
"NAME" => $_[2],
- "ELEMENTS" => $_[4]
+ "ELEMENTS" => $_[3]
}}
;
@@ -161,11 +168,13 @@ enum_element: identifier
| identifier '=' anytext { "$_[1]$_[2]$_[3]" }
;
-bitmap: 'bitmap' optional_identifier '{' bitmap_elements '}'
+bitmap_body: '{' bitmap_elements '}' { $_[2] };
+opt_bitmap_body: | bitmap_body;
+bitmap: 'bitmap' optional_identifier opt_bitmap_body
{{
"TYPE" => "BITMAP",
"NAME" => $_[2],
- "ELEMENTS" => $_[4]
+ "ELEMENTS" => $_[3]
}}
;
@@ -177,11 +186,14 @@ bitmap_elements:
bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" }
;
-struct: 'struct' optional_identifier '{' element_list1 '}'
+struct_body: '{' element_list1 '}' { $_[2] };
+opt_struct_body: | struct_body;
+
+struct: 'struct' optional_identifier opt_struct_body
{{
"TYPE" => "STRUCT",
"NAME" => $_[2],
- "ELEMENTS" => $_[4]
+ "ELEMENTS" => $_[3]
}}
;
@@ -200,7 +212,7 @@ empty_element: property_list ';'
base_or_empty: base_element ';' | empty_element;
optional_base_element:
- property_list base_or_empty { $_[2]->{PROPERTIES} = Parse::Pidl::Util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
+ property_list base_or_empty { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
;
union_elements:
@@ -208,11 +220,14 @@ union_elements:
| union_elements optional_base_element { push(@{$_[1]}, $_[2]); $_[1] }
;
-union: 'union' optional_identifier '{' union_elements '}'
+union_body: '{' union_elements '}' { $_[2] };
+opt_union_body: | union_body;
+
+union: 'union' optional_identifier opt_union_body
{{
"TYPE" => "UNION",
"NAME" => $_[2],
- "ELEMENTS" => $_[4]
+ "ELEMENTS" => $_[3]
}}
;
@@ -256,11 +271,11 @@ array_len:
property_list:
#empty
- | property_list '[' properties ']' { Parse::Pidl::Util::FlattenHash([$_[1],$_[3]]); }
+ | property_list '[' properties ']' { FlattenHash([$_[1],$_[3]]); }
;
properties: property { $_[1] }
- | properties ',' property { Parse::Pidl::Util::FlattenHash([$_[1], $_[3]]); }
+ | properties ',' property { FlattenHash([$_[1], $_[3]]); }
;
property: identifier {{ "$_[1]" => "1" }}
@@ -321,7 +336,21 @@ optional_semicolon:
# start code
%%
-use Parse::Pidl::Util;
+#####################################################################
+# flatten an array of hashes into a single hash
+sub FlattenHash($)
+{
+ my $a = shift;
+ my %b;
+ for my $d (@{$a}) {
+ for my $k (keys %{$d}) {
+ $b{$k} = $d->{$k};
+ }
+ }
+ return \%b;
+}
+
+
#####################################################################
# traverse a perl data structure removing any empty arrays or
@@ -405,7 +434,7 @@ again:
$parser->YYData->{LAST_TOKEN} = $1;
if ($1 =~
/^(coclass|interface|const|typedef|declare|union
- |struct|enum|bitmap|void)$/x) {
+ |struct|enum|bitmap|void|unsigned|signed)$/x) {
return $1;
}
return('IDENTIFIER',$1);