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;
21 #####################################################################
22 # parse an IDL file returning a structure containing all the data
25 # this autoaction allows us to handle simple nodes without an action
27 $::RD_AUTOACTION = q {
28 $#item==1 && ref($item[1]) eq "" ?
30 "XX_" . $item[0] . "_XX[$#item]" };
31 my($filename) = shift;
32 my($grammer) = util::FileLoad("idl.gram");
33 my($parser) = Parse::RecDescent->new($grammer);
35 my($idl) = $parser->idl(`cpp $filename`);
36 util::CleanData($idl);
41 #########################################
46 perl IDL parser and code generator
47 Copyright tridge\@samba.org
49 Usage: pidl.pl [options] <idlfile>
53 --parse parse a idl file to a .pidl file
54 --dump dump a pidl file back to idl
55 --diff run diff on the idl and dumped output
62 'help|h|?' => \$opt_help,
63 'parse' => \$opt_parse,
68 my($idl_file) = shift;
69 die "ERROR: You must specify an idl file to process" unless ($idl_file);
71 my($pidl_file) = util::ChangeExtension($idl_file, "pidl");
78 print "Parsing $idl_file\n";
79 my($idl) = IdlParse($idl_file);
80 print "Saving $pidl_file\n";
81 util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
85 my($idl) = util::LoadStructure($pidl_file);
86 print IdlDump::Dump($idl);
90 my($idl) = util::LoadStructure($pidl_file);
91 my($tempfile) = util::ChangeExtension($idl_file, "tmp");
92 util::FileSave($tempfile, IdlDump::Dump($idl));
93 system("diff -wu $idl_file $tempfile");