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] }
2006-11-07 00:54:19 +03:00
| idl import { push(@{$_[1]}, $_[2]); $_[1] }
| idl include { push(@{$_[1]}, $_[2]); $_[1] }
| idl importlib { push(@{$_[1]}, $_[2]); $_[1] }
2007-08-31 04:03:54 +04:00
| idl cpp_quote { push(@{$_[1]}, $_[2]); $_[1] }
2006-11-07 00:54:19 +03:00
;
2006-11-07 01:54:49 +03:00
import: 'import' commalist ';' {{
2006-11-07 00:54:19 +03:00
"TYPE" => "IMPORT",
2006-11-07 01:54:49 +03:00
"PATHS" => $_[2],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
2006-11-07 00:54:19 +03:00
"LINE" => $_[0]->YYData->{LINE}
}}
;
2006-11-07 01:54:49 +03:00
include: 'include' commalist ';' {{
2006-11-07 00:54:19 +03:00
"TYPE" => "INCLUDE",
2006-11-07 01:54:49 +03:00
"PATHS" => $_[2],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
2006-11-07 00:54:19 +03:00
"LINE" => $_[0]->YYData->{LINE}
}}
;
2006-11-07 01:54:49 +03:00
importlib: 'importlib' commalist ';' {{
2006-11-07 00:54:19 +03:00
"TYPE" => "IMPORTLIB",
2006-11-07 01:54:49 +03:00
"PATHS" => $_[2],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
2006-11-07 00:54:19 +03:00
"LINE" => $_[0]->YYData->{LINE}
}}
2004-11-01 23:00:02 +03:00
;
2006-11-07 01:54:49 +03:00
commalist:
text { [ $_[1] ] }
| commalist ',' text { push(@{$_[1]}, $_[3]); $_[1] }
;
2005-02-21 15:13:42 +03:00
coclass: property_list 'coclass' identifier '{' interface_names '}' optional_semicolon
2006-11-07 00:54:19 +03:00
{{
2004-11-01 23:00:02 +03:00
"TYPE" => "COCLASS",
2005-01-05 03:14:29 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"DATA" => $_[5],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"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
;
2007-03-04 17:16:52 +03:00
interface: property_list 'interface' identifier '{' definitions '}' optional_semicolon
2006-11-07 00:54:19 +03:00
{{
2004-08-11 23:48:36 +04:00
"TYPE" => "INTERFACE",
2005-01-05 03:14:29 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
2007-03-04 17:16:52 +03:00
"DATA" => $_[5],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
2007-08-31 04:03:54 +04:00
cpp_quote: 'cpp_quote' '(' text ')'
{{
"TYPE" => "CPP_QUOTE",
"FILE" => $_[0]->YYData->{FILE},
"LINE" => $_[0]->YYData->{LINE},
"DATA" => $_[3]
}}
;
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
;
2005-10-16 21:17:42 +04:00
const: 'const' identifier pointers identifier '=' anytext ';'
2003-12-07 16:38:07 +03:00
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
2005-10-16 21:17:42 +04:00
"POINTERS" => $_[3],
"NAME" => $_[4],
"VALUE" => $_[6],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
2005-10-16 21:17:42 +04:00
| 'const' identifier pointers identifier array_len '=' anytext ';'
2004-11-29 14:08:15 +03:00
{{
"TYPE" => "CONST",
"DTYPE" => $_[2],
2005-10-16 21:17:42 +04:00
"POINTERS" => $_[3],
"NAME" => $_[4],
"ARRAY_LEN" => $_[5],
"VALUE" => $_[7],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"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],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"LINE" => $_[0]->YYData->{LINE},
}}
2003-12-07 16:38:07 +03:00
;
2007-05-01 06:00:57 +04:00
declare: 'declare' decl_type identifier';'
2005-01-06 09:32:07 +03:00
{{
"TYPE" => "DECLARE",
2007-05-01 06:00:57 +04:00
"NAME" => $_[3],
"DATA" => $_[2],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"LINE" => $_[0]->YYData->{LINE},
2005-01-06 09:32:07 +03:00
}}
;
2006-07-29 10:00:58 +04:00
decl_type: decl_enum | decl_bitmap | decl_union
2005-01-06 09:32:07 +03:00
;
2007-05-01 06:00:57 +04:00
decl_enum: property_list 'enum'
2005-01-06 09:32:07 +03:00
{{
2007-05-01 06:00:57 +04:00
"TYPE" => "ENUM",
"PROPERTIES" => $_[1]
2005-01-06 09:32:07 +03:00
}}
;
2007-05-01 06:00:57 +04:00
decl_bitmap: property_list 'bitmap'
2005-01-06 09:32:07 +03:00
{{
2007-05-01 06:00:57 +04:00
"TYPE" => "BITMAP",
"PROPERTIES" => $_[1]
2005-01-06 09:32:07 +03:00
}}
;
2007-05-01 06:00:57 +04:00
decl_union: property_list 'union'
2006-07-29 10:00:58 +04:00
{{
2007-05-01 06:00:57 +04:00
"TYPE" => "UNION",
"PROPERTIES" => $_[1]
2006-07-29 10:00:58 +04:00
}}
;
2007-02-18 19:21:28 +03:00
typedef: property_list 'typedef' type identifier array_len ';'
2003-12-07 16:38:07 +03:00
{{
2005-01-05 02:25:25 +03:00
"TYPE" => "TYPEDEF",
2007-02-18 19:21:28 +03:00
"PROPERTIES" => $_[1],
2005-01-05 02:25:25 +03:00
"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],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"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] };
2005-12-25 17:59:21 +03:00
sign: 'signed' | 'unsigned';
existingtype:
2007-01-09 09:02:41 +03:00
sign identifier { ($_[1]?$_[1]:"signed") ." $_[2]" }
2005-12-25 17:59:21 +03:00
| identifier
2003-12-07 16:38:07 +03:00
;
2005-12-25 17:59:21 +03:00
type: usertype | existingtype | void { "void" } ;
enum_body: '{' enum_elements '}' { $_[2] };
opt_enum_body: | enum_body;
2007-02-18 19:21:28 +03:00
enum: property_list 'enum' optional_identifier opt_enum_body
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",
2007-02-18 19:21:28 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"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]" }
;
2006-09-07 02:25:54 +04:00
bitmap_body: '{' opt_bitmap_elements '}' { $_[2] };
2005-12-25 17:59:21 +03:00
opt_bitmap_body: | bitmap_body;
2007-02-18 19:21:28 +03:00
bitmap: property_list 'bitmap' optional_identifier opt_bitmap_body
2005-01-05 18:26:48 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "BITMAP",
2007-02-18 19:21:28 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"ELEMENTS" => $_[4]
2005-01-05 18:26:48 +03:00
}}
;
bitmap_elements:
bitmap_element { [ $_[1] ] }
| bitmap_elements ',' bitmap_element { push(@{$_[1]}, $_[3]); $_[1] }
;
2006-09-07 02:25:54 +04:00
opt_bitmap_elements: | bitmap_elements;
2005-01-05 18:26:48 +03:00
bitmap_element: identifier '=' anytext { "$_[1] ( $_[3] )" }
;
2005-12-25 17:59:21 +03:00
struct_body: '{' element_list1 '}' { $_[2] };
opt_struct_body: | struct_body;
2007-02-18 19:21:28 +03:00
struct: property_list 'struct' optional_identifier opt_struct_body
2003-12-07 16:38:07 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "STRUCT",
2007-02-18 19:21:28 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"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" => [],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"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-12-25 17:59:21 +03:00
property_list base_or_empty { $_[2]->{PROPERTIES} = 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-12-25 17:59:21 +03:00
union_body: '{' union_elements '}' { $_[2] };
opt_union_body: | union_body;
2007-02-18 19:21:28 +03:00
union: property_list 'union' optional_identifier opt_union_body
2005-02-11 05:05:47 +03:00
{{
2005-07-20 03:34:02 +04:00
"TYPE" => "UNION",
2007-02-18 19:21:28 +03:00
"PROPERTIES" => $_[1],
"NAME" => $_[3],
"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],
2007-01-05 18:20:23 +03:00
"FILE" => $_[0]->YYData->{FILE},
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
"LINE" => $_[0]->YYData->{LINE},
2003-12-07 16:38:07 +03:00
}}
;
pointers:
#empty
{ 0 }
| pointers '*' { $_[1]+1 }
;
element_list1:
2007-03-04 17:16:52 +03:00
{ [] }
2003-12-07 16:38:07 +03:00
| 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-12-25 17:59:21 +03:00
| property_list '[' properties ']' { FlattenHash([$_[1],$_[3]]); }
2003-12-07 16:38:07 +03:00
;
2003-12-08 05:55:28 +03:00
properties: property { $_[1] }
2005-12-25 17:59:21 +03:00
| properties ',' property { 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
%%
2007-01-05 18:20:23 +03:00
use Parse::Pidl qw(error);
2005-12-25 17:59:21 +03:00
#####################################################################
# 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;
}
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;
2005-12-25 02:32:50 +03:00
return undef if (not defined($v));
2005-07-10 05:16:02 +04:00
if (ref($v) eq "ARRAY") {
foreach my $i (0 .. $#{$v}) {
CleanData($v->[$i]);
}
# 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; }
}
}
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}) {
2007-01-05 18:20:23 +03:00
error($_[0]->YYData, $_[0]->YYData->{ERRMSG});
2003-12-07 16:38:07 +03:00
delete $_[0]->YYData->{ERRMSG};
return;
};
my $last_token = $_[0]->YYData->{LAST_TOKEN};
2007-01-05 18:20:23 +03:00
error($_[0]->YYData, "Syntax error near '$last_token'");
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;
2007-01-05 18:20:23 +03:00
$parser->YYData->{FILE} = $2;
2003-12-07 16:51:23 +03:00
goto again;
}
2003-12-16 03:38:33 +03:00
if (s/^\#line (\d+) \"(.*?)\"( \d+|)//) {
$parser->YYData->{LINE} = $1-1;
2007-01-05 18:20:23 +03:00
$parser->YYData->{FILE} = $2;
2003-12-16 03:38:33 +03:00
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 =~
2007-08-31 04:03:54 +04:00
/^(coclass|interface|const|typedef|declare|union|cpp_quote
2006-11-07 00:54:19 +03:00
|struct|enum|bitmap|void|unsigned|signed|import|include
|importlib)$/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);
}
}
}
2005-12-25 02:32:50 +03:00
sub parse_string
2003-12-07 16:38:07 +03:00
{
2005-12-25 02:32:50 +03:00
my ($data,$filename) = @_;
2005-12-25 00:57:51 +03:00
my $self = new Parse::Pidl::IDL;
2007-01-05 18:20:23 +03:00
$self->YYData->{FILE} = $filename;
2005-12-25 00:57:51 +03:00
$self->YYData->{INPUT} = $data;
$self->YYData->{LINE} = 0;
$self->YYData->{LAST_TOKEN} = "NONE";
my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
return CleanData($idl);
}
2006-11-06 23:01:22 +03:00
sub parse_file($$)
2005-12-25 00:57:51 +03:00
{
2006-11-06 23:01:22 +03:00
my ($filename,$incdirs) = @_;
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
}
2006-11-07 04:00:27 +03:00
my $includes = join('',map { " -I$_" } @$incdirs);
2006-11-06 23:01:22 +03:00
my $data = `$cpp -D__PIDL__$includes -xc $filename`;
2003-12-07 16:38:07 +03:00
$/ = $saved_delim;
2005-12-25 02:32:50 +03:00
return parse_string($data, $filename);
2003-12-07 16:38:07 +03:00
}