git.samba.org
/
samba.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4bad800
)
beginnings of the C parser generator
author
Andrew Tridgell
<tridge@samba.org>
Thu, 14 Dec 2000 23:53:19 +0000
(23:53 +0000)
committer
Andrew Tridgell
<tridge@samba.org>
Thu, 14 Dec 2000 23:53:19 +0000
(23:53 +0000)
(This used to be commit
a9b1e03b334a2ad106b3f42a513565b530baba93
)
source4/build/pidl/pidl.pl
patch
|
blob
|
history
diff --git
a/source4/build/pidl/pidl.pl
b/source4/build/pidl/pidl.pl
index 3af933685cf66d0c61390f80be3be7d7133915df..7ac7d5860f8af39e6f82757f975463d9d504eadf 100755
(executable)
--- 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 Parse::RecDescent;
use dump;
use header;
+use parser;
use util;
my($opt_help) = 0;
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_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
#####################################################################
# 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($filename) = shift;
my($grammer) = util::FileLoad("idl.gram");
my($parser) = Parse::RecDescent->new($grammer);
+ my($saved_sep) = $/;
undef $/;
my($idl) = $parser->idl(`cpp $filename`);
undef $/;
my($idl) = $parser->idl(`cpp $filename`);
+ $/ = $saved_sep;
util::CleanData($idl);
return $idl;
}
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
--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);
--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,
'parse' => \$opt_parse,
'dump' => \$opt_dump,
'header' => \$opt_header,
+ 'parser' => \$opt_parser,
'diff' => \$opt_diff
);
'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) {
my($pidl_file) = util::ChangeExtension($idl_file, "pidl");
if ($opt_parse) {
- print "
Parsing $
idl_file\n";
+ print "
Generating $p
idl_file\n";
my($idl) = IdlParse($idl_file);
my($idl) = IdlParse($idl_file);
- print "Saving $pidl_file\n";
util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file";
}
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");
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));
}
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");
if ($opt_diff) {
my($idl) = util::LoadStructure($pidl_file);
my($tempfile) = util::ChangeExtension($idl_file, "tmp");