3 ###################################################
4 # package to parse IDL files and generate code for
5 # rpc functions in Samba
6 # Copyright tridge@samba.org 2000
7 # released under the GNU GPL
12 use Parse::RecDescent;
25 #####################################################################
26 # parse an IDL file returning a structure containing all the data
29 # this autoaction allows us to handle simple nodes without an action
31 $::RD_AUTOACTION = q {
32 $#item==1 && ref($item[1]) eq "" ?
34 "XX_" . $item[0] . "_XX[$#item]" };
35 my($filename) = shift;
36 my($grammer) = util::FileLoad("idl.gram");
37 my($parser) = Parse::RecDescent->new($grammer);
40 my($idl) = $parser->idl(`cpp $filename`);
42 util::CleanData($idl);
47 #########################################
52 perl IDL parser and code generator
53 Copyright tridge\@samba.org
55 Usage: pidl.pl [options] <idlfile>
59 --parse parse a idl file to a .pidl file
60 --dump dump a pidl file back to idl
61 --header create a C header file
62 --parser create a C parser
63 --diff run diff on the idl and dumped output
70 'help|h|?' => \$opt_help,
71 'parse' => \$opt_parse,
73 'header' => \$opt_header,
74 'parser' => \$opt_parser,
83 my($idl_file) = shift;
84 die "ERROR: You must specify an idl file to process" unless ($idl_file);
86 my($pidl_file) = util::ChangeExtension($idl_file, "pidl");
89 print "Generating $pidl_file\n";
90 my($idl) = IdlParse($idl_file);
91 util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
95 my($idl) = util::LoadStructure($pidl_file);
96 print IdlDump::Dump($idl);
100 my($idl) = util::LoadStructure($pidl_file);
101 my($header) = util::ChangeExtension($idl_file, "h");
102 print "Generating $header\n";
103 util::FileSave($header, IdlHeader::Dump($idl));
107 my($idl) = util::LoadStructure($pidl_file);
108 my($parser) = util::ChangeExtension($idl_file, "c");
109 print "Generating $parser\n";
110 util::FileSave($parser, IdlParser::Dump($idl));
114 my($idl) = util::LoadStructure($pidl_file);
115 my($tempfile) = util::ChangeExtension($idl_file, "tmp");
116 util::FileSave($tempfile, IdlDump::Dump($idl));
117 system("diff -wu $idl_file $tempfile");