summaryrefslogtreecommitdiff
path: root/source4/build/pidl/pidl.pl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-12-14 23:53:19 +0000
committerAndrew Tridgell <tridge@samba.org>2000-12-14 23:53:19 +0000
commite42a8b3db990af12fad73b63fcc7db9fda125625 (patch)
tree3e0f8dcd939f529160f542b28c9e168befb365fb /source4/build/pidl/pidl.pl
parent4bad800aa158bed0183ce02b30ea22ab6534eb7a (diff)
downloadsamba-e42a8b3db990af12fad73b63fcc7db9fda125625.tar.gz
samba-e42a8b3db990af12fad73b63fcc7db9fda125625.tar.bz2
samba-e42a8b3db990af12fad73b63fcc7db9fda125625.zip
beginnings of the C parser generator
(This used to be commit a9b1e03b334a2ad106b3f42a513565b530baba93)
Diffstat (limited to 'source4/build/pidl/pidl.pl')
-rwxr-xr-xsource4/build/pidl/pidl.pl19
1 files changed, 16 insertions, 3 deletions
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl
index 3af933685c..7ac7d5860f 100755
--- a/source4/build/pidl/pidl.pl
+++ b/source4/build/pidl/pidl.pl
@@ -12,6 +12,7 @@ use Data::Dumper;
use Parse::RecDescent;
use dump;
use header;
+use parser;
use util;
my($opt_help) = 0;
@@ -19,6 +20,7 @@ my($opt_parse) = 0;
my($opt_dump) = 0;
my($opt_diff) = 0;
my($opt_header) = 0;
+my($opt_parser) = 0;
#####################################################################
# parse an IDL file returning a structure containing all the data
@@ -33,8 +35,10 @@ sub IdlParse($)
my($filename) = shift;
my($grammer) = util::FileLoad("idl.gram");
my($parser) = Parse::RecDescent->new($grammer);
+ my($saved_sep) = $/;
undef $/;
my($idl) = $parser->idl(`cpp $filename`);
+ $/ = $saved_sep;
util::CleanData($idl);
return $idl;
}
@@ -54,7 +58,8 @@ sub ShowHelp()
--help this help page
--parse parse a idl file to a .pidl file
--dump dump a pidl file back to idl
- --header dump a C header file
+ --header create a C header file
+ --parser create a C parser
--diff run diff on the idl and dumped output
\n";
exit(0);
@@ -66,6 +71,7 @@ GetOptions (
'parse' => \$opt_parse,
'dump' => \$opt_dump,
'header' => \$opt_header,
+ 'parser' => \$opt_parser,
'diff' => \$opt_diff
);
@@ -80,9 +86,8 @@ die "ERROR: You must specify an idl file to process" unless ($idl_file);
my($pidl_file) = util::ChangeExtension($idl_file, "pidl");
if ($opt_parse) {
- print "Parsing $idl_file\n";
+ print "Generating $pidl_file\n";
my($idl) = IdlParse($idl_file);
- print "Saving $pidl_file\n";
util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
}
@@ -94,9 +99,17 @@ if ($opt_dump) {
if ($opt_header) {
my($idl) = util::LoadStructure($pidl_file);
my($header) = util::ChangeExtension($idl_file, "h");
+ print "Generating $header\n";
util::FileSave($header, IdlHeader::Dump($idl));
}
+if ($opt_parser) {
+ my($idl) = util::LoadStructure($pidl_file);
+ my($parser) = util::ChangeExtension($idl_file, "c");
+ print "Generating $parser\n";
+ util::FileSave($parser, IdlParser::Dump($idl));
+}
+
if ($opt_diff) {
my($idl) = util::LoadStructure($pidl_file);
my($tempfile) = util::ChangeExtension($idl_file, "tmp");