1#!/usr/bin/perl 2# $Id: gen-conf-ref.pl,v 1.1 2009-08-25 16:22:44 sampo Exp $ 3# 21.8.2009, Sampo Kellomaki <sampo@iki.fi> 4# 5# Generate configuration reference from zxidconf.h specially 6# maerked comments 7 8$usage = <<USAGE; 9Usage: ./gen-conf-ref.pl [opts] <zxidconf.h >confref.pd 10USAGE 11 ; 12 13$project = 'ZXID'; 14 15$write = 1; 16if ($ARGV[0] eq '-n') { 17 shift; 18 $write = 0; 19} 20 21use Data::Dumper; 22die $USAGE if $ARGV[0] =~ /^-/; 23select STDERR; $|=1; select STDOUT; 24undef $/; 25$x = <STDIN>; 26 27# 1 1 2 2 3 3 28@a = split /(?:\n\/\*\((c)\)[ ]*([^\n]+)\s*(.+?)\*\/)/gsx, $x; 29 30shift @a; # Starting comment 31 32while (@a) { 33 ++$n; 34 $docflag = shift @a; 35 $title = shift @a; 36 $comment = shift @a; 37 $body = shift @a; 38 39 $comment =~ s/^\* //s; 40 $comment =~ s/\*\/$//gs; 41 $comment =~ s/\n ?\* ?/\n/gs; 42 43 print <<PD; 44 454.1.$n $title 46~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47 48$comment 49 50PD 51 ; 52 53 # 1 1 2 2 3 34 5 5 4 54 @opts = $body =~ m/^\#define ZX(ID_)?(\w+) +(.+?)( *\/\* *(.*?) *\*\/)?$/gm; 55 #warn "opts($body): " . Dumper \@opts if $n == 2 || $n == 4; 56 while (@opts) { 57 shift @opts; 58 $opt_name = shift @opts; 59 $opt_val = shift @opts; 60 shift @opts; 61 $opt_comment = shift @opts; 62 63 print "${opt_name}:: $opt_comment (default: $opt_val)\n\n"; 64 } 65 66 #warn "\n\n=======\n$comment"; 67} 68 69exit; 70 71#EOF gen-conf-ref.pl 72