2003-12-07 16:38:07 +03:00
########################
# IDL Parse::Yapp parser
# Copyright (C) Andrew Tridgell <tridge@samba.org>
# released under the GNU GPL version 2 or later
2005-08-01 05:39:24 +04:00
# the precedence actually doesn't matter at all for this grammar, but
2003-12-08 05:24:40 +03:00
# by providing a precedence we reduce the number of conflicts
# enormously
%left '-' '+' '&' '|' '*' '>' '.' '/' '(' ')' '[' ',' ';'
2003-12-07 16:38:07 +03:00
################
2005-08-01 05:39:24 +04:00
# grammar
2003-12-07 16:38:07 +03:00
%%
2004-08-11 23:48:36 +04:00
idl:
#empty { {} }
2005-01-05 18:26:48 +03:00
| idl interface { push(@{$_[1]}, $_[2]); $_[1] }
2004-11-01 23:00:02 +03:00
| idl coclass { push(@{$_[1]}, $_[2]); $_[1] }
;
2005-02-21 15:13:42 +03:00
coclass: property_list 'coclass' identifier '{' interface_names '}' optional_semicolon
2004-11-01 23:00:02 +03:00
{$_[3] => {
"TYPE" => "COCLASS",
2005-01-05 03:14:29 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"DATA" => $_[5],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2004-11-01 23:00:02 +03:00
}}
;
2005-02-21 15:13:42 +03:00
interface_names:
2004-11-01 23:00:02 +03:00
#empty { {} }
2005-02-21 15:13:42 +03:00
| interface_names 'interface' identifier ';' { push(@{$_[1]}, $_[2]); $_[1] }
2003-12-07 16:38:07 +03:00
;
2004-11-01 15:26:59 +03:00
interface: property_list 'interface' identifier base_interface '{' definitions '}' optional_semicolon
2004-08-11 23:48:36 +04:00
{$_[3] => {
"TYPE" => "INTERFACE",
2005-01-05 03:14:29 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"BASE" => $_[4],
"DATA" => $_[6],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
2004-08-11 23:48:36 +04:00
base_interface:
#empty
| ':' identifier { $_[2] }
2003-12-07 16:38:07 +03:00
;
definitions:
definition { [ $_[1] ] }
| definitions definition { push(@{$_[1]}, $_[2]); $_[1] }
;
2005-07-20 03:34:02 +04:00
definition: function | const | typedef | declare | typedecl
2003-12-07 16:38:07 +03:00
;
const: 'const' identifier identifier '=' anytext ';'
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
"NAME" => $_[3],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"VALUE" => $_[5],
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
2004-11-29 14:08:15 +03:00
| 'const' identifier identifier array_len '=' anytext ';'
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
"NAME" => $_[3],
"ARRAY_LEN" => $_[4],
"VALUE" => $_[6],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2004-11-29 14:08:15 +03:00
}}
2003-12-07 16:38:07 +03:00
;
function: property_list type identifier '(' element_list2 ')' ';'
{{
"TYPE" => "FUNCTION",
"NAME" => $_[3],
"RETURN_TYPE" => $_[2],
"PROPERTIES" => $_[1],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"ELEMENTS" => $_[5],
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
}}
2003-12-07 16:38:07 +03:00
;
2005-01-06 09:32:07 +03:00
declare: 'declare' property_list decl_type identifier';'
{{
"TYPE" => "DECLARE",
"PROPERTIES" => $_[2],
"NAME" => $_[4],
"DATA" => $_[3],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2005-01-06 09:32:07 +03:00
}}
;
decl_type: decl_enum | decl_bitmap
;
decl_enum: 'enum'
{{
"TYPE" => "ENUM"
}}
;
decl_bitmap: 'bitmap'
{{
"TYPE" => "BITMAP"
}}
;
2005-01-05 02:25:25 +03:00
typedef: 'typedef' property_list type identifier array_len ';'
2003-12-07 16:38:07 +03:00
{{
2005-01-05 02:25:25 +03:00
"TYPE" => "TYPEDEF",
"PROPERTIES" => $_[2],
"NAME" => $_[4],
"DATA" => $_[3],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"ARRAY_LEN" => $_[5],
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
2005-07-20 03:34:02 +04:00
usertype: struct | union | enum | bitmap;
typedecl: usertype ';' { $_[1] };
type: usertype | identifier
2003-12-07 16:38:07 +03:00
| void { "void" }
;
2005-07-20 03:34:02 +04:00
enum: 'enum' optional_identifier '{' enum_elements '}'
2003-12-07 16:38:07 +03:00
{{
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"TYPE" => "ENUM",
2005-07-20 03:34:02 +04:00
"NAME" => $_[2],
"ELEMENTS" => $_[4]
2003-12-07 16:38:07 +03:00
}}
;
enum_elements:
enum_element { [ $_[1] ] }
| enum_elements ',' enum_element { push(@{$_[1]}, $_[3]); $_[1] }
;
enum_element: identifier
| identifier '=' anytext { "$_[1]$_[2]$_[3]" }
;
2005-07-20 03:34:02 +04:00
bitmap: 'bitmap' optional_identifier '{' bitmap_elements '}'
2005-01-05 18:26:48 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "BITMAP",
"NAME" => $_[2],
"ELEMENTS" => $_[4]
2005-01-05 18:26:48 +03:00
}}
;
bitmap_elements:
bitmap_element { [ $_[1] ] }
| bitmap_elements ',' bitmap_element { push(@{$_[1]}, $_[3]); $_[1] }
;
bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" }
;
2005-07-20 03:34:02 +04:00
struct: 'struct' optional_identifier '{' element_list1 '}'
2003-12-07 16:38:07 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "STRUCT",
"NAME" => $_[2],
"ELEMENTS" => $_[4]
2003-12-07 16:38:07 +03:00
}}
;
2005-02-11 05:05:47 +03:00
empty_element: property_list ';'
{{
"NAME" => "",
"TYPE" => "EMPTY",
2005-03-28 22:22:45 +04:00
"PROPERTIES" => $_[1],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"POINTERS" => 0,
2005-05-27 18:01:22 +04:00
"ARRAY_LEN" => [],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
2005-02-11 05:05:47 +03:00
base_or_empty: base_element ';' | empty_element;
optional_base_element:
2005-07-09 19:32:08 +04:00
property_list base_or_empty { $_[2]->{PROPERTIES} = Parse::Pidl::Util::FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] }
2005-02-11 05:05:47 +03:00
;
2003-12-07 16:38:07 +03:00
union_elements:
2005-02-11 05:05:47 +03:00
#empty
| union_elements optional_base_element { push(@{$_[1]}, $_[2]); $_[1] }
2003-12-07 16:38:07 +03:00
;
2005-07-20 03:34:02 +04:00
union: 'union' optional_identifier '{' union_elements '}'
2005-02-11 05:05:47 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "UNION",
"NAME" => $_[2],
"ELEMENTS" => $_[4]
2005-02-11 05:05:47 +03:00
}}
2003-12-07 16:38:07 +03:00
;
base_element: property_list type pointers identifier array_len
{{
"NAME" => $_[4],
"TYPE" => $_[2],
"PROPERTIES" => $_[1],
"POINTERS" => $_[3],
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
"ARRAY_LEN" => $_[5],
"FILE" => $_[0]->YYData->{INPUT_FILENAME},
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
pointers:
#empty
{ 0 }
| pointers '*' { $_[1]+1 }
;
element_list1:
#empty
| element_list1 base_element ';' { push(@{$_[1]}, $_[2]); $_[1] }
;
element_list2:
#empty
2003-12-08 05:24:40 +03:00
| 'void'
| base_element { [ $_[1] ] }
2003-12-07 16:38:07 +03:00
| element_list2 ',' base_element { push(@{$_[1]}, $_[3]); $_[1] }
;
array_len:
2005-05-27 18:01:22 +04:00
#empty { [] }
| '[' ']' array_len { push(@{$_[3]}, "*"); $_[3] }
| '[' anytext ']' array_len { push(@{$_[4]}, "$_[2]"); $_[4] }
2003-12-07 16:38:07 +03:00
;
property_list:
2003-12-08 05:24:40 +03:00
#empty
2005-07-09 19:32:08 +04:00
| property_list '[' properties ']' { Parse::Pidl::Util::FlattenHash([$_[1],$_[3]]); }
2003-12-07 16:38:07 +03:00
;
2003-12-08 05:55:28 +03:00
properties: property { $_[1] }
2005-07-09 19:32:08 +04:00
| properties ',' property { Parse::Pidl::Util::FlattenHash([$_[1], $_[3]]); }
2003-12-07 16:38:07 +03:00
;
2003-12-08 05:55:28 +03:00
property: identifier {{ "$_[1]" => "1" }}
2004-08-11 23:48:36 +04:00
| identifier '(' listtext ')' {{ "$_[1]" => "$_[3]" }}
2003-12-07 16:38:07 +03:00
;
listtext:
anytext
| listtext ',' anytext { "$_[1] $_[3]" }
;
2004-10-14 14:30:08 +04:00
commalisttext:
anytext
| commalisttext ',' anytext { "$_[1],$_[3]" }
;
2003-12-07 16:38:07 +03:00
anytext: #empty
{ "" }
| identifier | constant | text
| anytext '-' anytext { "$_[1]$_[2]$_[3]" }
| anytext '.' anytext { "$_[1]$_[2]$_[3]" }
| anytext '*' anytext { "$_[1]$_[2]$_[3]" }
| anytext '>' anytext { "$_[1]$_[2]$_[3]" }
2005-01-21 09:46:07 +03:00
| anytext '<' anytext { "$_[1]$_[2]$_[3]" }
2003-12-07 16:38:07 +03:00
| anytext '|' anytext { "$_[1]$_[2]$_[3]" }
| anytext '&' anytext { "$_[1]$_[2]$_[3]" }
| anytext '/' anytext { "$_[1]$_[2]$_[3]" }
2005-09-04 02:57:30 +04:00
| anytext '?' anytext { "$_[1]$_[2]$_[3]" }
| anytext ':' anytext { "$_[1]$_[2]$_[3]" }
| anytext '=' anytext { "$_[1]$_[2]$_[3]" }
2003-12-07 16:38:07 +03:00
| anytext '+' anytext { "$_[1]$_[2]$_[3]" }
2005-05-27 22:14:43 +04:00
| anytext '~' anytext { "$_[1]$_[2]$_[3]" }
2004-10-14 14:30:08 +04:00
| anytext '(' commalisttext ')' anytext { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2004-11-29 14:08:15 +03:00
| anytext '{' commalisttext '}' anytext { "$_[1]$_[2]$_[3]$_[4]$_[5]" }
2003-12-07 16:38:07 +03:00
;
identifier: IDENTIFIER
;
2005-07-20 03:34:02 +04:00
optional_identifier:
IDENTIFIER
| #empty { undef }
;
2003-12-07 16:38:07 +03:00
constant: CONSTANT
;
text: TEXT { "\"$_[1]\"" }
;
2004-11-01 15:26:59 +03:00
optional_semicolon:
#empty
| ';'
;
2003-12-07 16:38:07 +03:00
#####################################
# start code
%%
2005-07-09 19:32:08 +04:00
use Parse::Pidl::Util;
2003-12-07 16:38:07 +03:00
2005-07-10 05:16:02 +04:00
#####################################################################
# traverse a perl data structure removing any empty arrays or
# hashes and any hash elements that map to undef
sub CleanData($)
{
sub CleanData($);
my($v) = shift;
if (ref($v) eq "ARRAY") {
foreach my $i (0 .. $#{$v}) {
CleanData($v->[$i]);
if (ref($v->[$i]) eq "ARRAY" && $#{$v->[$i]}==-1) {
$v->[$i] = undef;
next;
}
}
# this removes any undefined elements from the array
@{$v} = grep { defined $_ } @{$v};
} elsif (ref($v) eq "HASH") {
foreach my $x (keys %{$v}) {
CleanData($v->{$x});
if (!defined $v->{$x}) { delete($v->{$x}); next; }
if (ref($v->{$x}) eq "ARRAY" && $#{$v->{$x}}==-1) { delete($v->{$x}); next; }
}
}
return $v;
}
2003-12-07 16:38:07 +03:00
sub _Error {
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
2005-05-25 17:50:27 +04:00
if (exists $_[0]->YYData->{ERRMSG}) {
2003-12-07 16:38:07 +03:00
print $_[0]->YYData->{ERRMSG};
delete $_[0]->YYData->{ERRMSG};
return;
};
my $line = $_[0]->YYData->{LINE};
my $last_token = $_[0]->YYData->{LAST_TOKEN};
my $file = $_[0]->YYData->{INPUT_FILENAME};
2004-05-14 22:35:51 +04:00
print "$file:$line: Syntax error near '$last_token'\n";
2003-12-07 16:38:07 +03:00
}
2003-12-07 16:51:23 +03:00
sub _Lexer($)
{
2003-12-07 16:38:07 +03:00
my($parser)=shift;
2005-07-22 01:27:39 +04:00
$parser->YYData->{INPUT} or return('',undef);
2003-12-07 16:38:07 +03:00
again:
$parser->YYData->{INPUT} =~ s/^[ \t]*//;
for ($parser->YYData->{INPUT}) {
2003-12-07 16:51:23 +03:00
if (/^\#/) {
if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
$parser->YYData->{LINE} = $1-1;
$parser->YYData->{INPUT_FILENAME} = $2;
goto again;
}
2003-12-16 03:38:33 +03:00
if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
$parser->YYData->{LINE} = $1-1;
$parser->YYData->{INPUT_FILENAME} = $2;
goto again;
}
if (s/^(\#.*)$//m) {
goto again;
}
2003-12-07 16:38:07 +03:00
}
if (s/^(\n)//) {
$parser->YYData->{LINE}++;
goto again;
}
if (s/^\"(.*?)\"//) {
$parser->YYData->{LAST_TOKEN} = $1;
return('TEXT',$1);
}
if (s/^(\d+)(\W|$)/$2/) {
$parser->YYData->{LAST_TOKEN} = $1;
return('CONSTANT',$1);
}
if (s/^([\w_]+)//) {
$parser->YYData->{LAST_TOKEN} = $1;
if ($1 =~
2005-01-06 09:32:07 +03:00
/^(coclass|interface|const|typedef|declare|union
2005-02-11 05:05:47 +03:00
|struct|enum|bitmap|void)$/x) {
2003-12-07 16:38:07 +03:00
return $1;
}
return('IDENTIFIER',$1);
}
if (s/^(.)//s) {
$parser->YYData->{LAST_TOKEN} = $1;
return($1,$1);
}
}
}
sub parse_idl($$)
{
2005-07-22 01:27:39 +04:00
my ($self,$filename) = @_;
2003-12-07 16:38:07 +03:00
my $saved_delim = $/;
undef $/;
2003-12-16 01:06:18 +03:00
my $cpp = $ENV{CPP};
if (! defined $cpp) {
2005-09-09 01:59:40 +04:00
$cpp = "cpp";
2003-12-16 01:06:18 +03:00
}
2005-06-01 04:34:28 +04:00
my $data = `$cpp -D__PIDL__ -xc $filename`;
2003-12-07 16:38:07 +03:00
$/ = $saved_delim;
2004-08-11 23:48:36 +04:00
$self->YYData->{INPUT} = $data;
$self->YYData->{LINE} = 0;
$self->YYData->{LAST_TOKEN} = "NONE";
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
2005-07-10 05:16:02 +04:00
return CleanData($idl);
2003-12-07 16:38:07 +03:00
}