3 # Read the source-form of the NASM manual and generate the various
8 # Ellipsis support would be nice.
10 # Source-form features:
11 # ---------------------
14 # Bullets the paragraph. Rest of paragraph is indented to cope. In
15 # HTML, consecutive groups of bulleted paragraphs become unordered
19 # produces `_foobar_' in text and italics in HTML, PS, RTF
21 # Inline code \c{foobar}
22 # produces ``foobar'' in text, and fixed-pitch font in HTML, PS, RTF
27 # produces fixed-pitch font where appropriate, and doesn't break
28 # pages except sufficiently far into the middle of a display.
30 # Chapter, header and subheader
31 # \C{intro} Introduction
32 # \H{whatsnasm} What is NASM?
33 # \S{free} NASM Is Free
34 # dealt with as appropriate. Chapters begin on new sides, possibly
35 # even new _pages_. (Sub)?headers are good places to begin new
36 # pages. Just _after_ a (sub)?header isn't.
37 # The keywords can be substituted with \K and \k.
39 # Keyword \K{cintro} \k{cintro}
40 # Expands to `Chapter 1', `Section 1.1', `Section 1.1.1'. \K has an
41 # initial capital whereas \k doesn't. In HTML, will produce
44 # Web link \W{http://foobar/}{text} or \W{mailto:me@here}\c{me@here}
45 # the \W prefix is ignored except in HTML; in HTML the last part
46 # becomes a hyperlink to the first part.
49 # In case it's necessary, they expand to the real versions.
51 # Nonbreaking hyphen \-
55 # Causes everything after it on the line to be ignored by the
56 # source-form processor.
58 # Indexable word \i{foobar} (or \i\e{foobar} or \i\c{foobar}, equally)
59 # makes word appear in index, referenced to that point
60 # \i\c comes up in code style even in the index; \i\e doesn't come
61 # up in emphasised style.
63 # Indexable non-displayed word \I{foobar} or \I\c{foobar}
64 # just as \i{foobar} except that nothing is displayed for it
67 # \IR{foobar} \c{foobar} operator, uses of
68 # tidies up the appearance in the index of something the \i or \I
69 # operator was applied to
72 # \IA{foobar}{bazquux}
73 # aliases one index tag (as might be supplied to \i or \I) to
74 # another, so that \I{foobar} has the effect of \I{bazquux}, and
75 # \i{foobar} has the effect of \I{bazquux}foobar
79 # defines document metadata, such as authorship, title and copyright;
80 # different output formats use this differently.
83 $diag = 1, shift @ARGV if $ARGV[0] eq "-d";
87 $tstruct_previtem = $node = "Top";
89 $tstruct_level{$tstruct_previtem} = 0;
90 $tstruct_last[$tstruct_level{$tstruct_previtem}] = $tstruct_previtem;
91 $MAXLEVEL = 10; # really 3, but play safe ;-)
93 # Read the file; pass a paragraph at a time to the paragraph processor.
94 print "Reading input...";
95 $pname = "para000000";
96 @pnames = @pflags = ();
100 if (!/\S/ || /^\\(IA|IR|M)/) { # special case: \IA \IR \M imply new-paragraph
105 s/\\#.*$//; # strip comments
112 # Now we've read in the entire document and we know what all the
113 # heading keywords refer to. Go through and fix up the \k references.
114 print "Fixing up cross-references...";
118 # Sort the index tags, according to the slightly odd order I've decided on.
119 print "Sorting index tags...";
124 print "Writing index-diagnostic file...";
129 # OK. Write out the various output files.
130 print "Producing text output: ";
133 print "Producing HTML output: ";
136 print "Producing PostScript output: ";
139 print "Producing Texinfo output: ";
142 print "Producing WinHelp output: ";
145 print "Producing Documentation Intermediate Paragraphs: ";
151 my $pflags = "", $i, $w, $l, $t;
156 # Strip off _leading_ spaces, then determine type of paragraph.
160 # A code paragraph. The paragraph-array will contain the simple
161 # strings which form each line of the paragraph.
163 while (/^\\c (([^\\]|\\[^c])*)(.*)$/) {
171 $_ = ''; # suppress word-by-word code
173 # A chapter heading. Define the keyword and allocate a chapter
178 $xref = "chapter-$cnum";
179 $pflags = "chap $cnum :$xref";
180 die "badly formatted chapter heading: $_\n" if !/^\\C{([^}]*)}\s*(.*)$/;
181 $refs{$1} = "chapter $cnum";
182 $node = "Chapter $cnum";
184 $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node;
187 # the standard word-by-word code will happen next
189 # An appendix heading. Define the keyword and allocate an appendix
192 $cnum = 'A' if $cnum =~ /[0-9]+/;
195 $xref = "appendix-$cnum";
196 $pflags = "appn $cnum :$xref";
197 die "badly formatted appendix heading: $_\n" if !/^\\A{([^}]*)}\s*(.*)$/;
198 $refs{$1} = "appendix $cnum";
199 $node = "Appendix $cnum";
201 $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node;
204 # the standard word-by-word code will happen next
206 # A major heading. Define the keyword and allocate a section number.
209 $xref = "section-$cnum.$hnum";
210 $pflags = "head $cnum.$hnum :$xref";
211 die "badly formatted heading: $_\n" if !/^\\[HP]{([^}]*)}\s*(.*)$/;
212 $refs{$1} = "section $cnum.$hnum";
213 $node = "Section $cnum.$hnum";
215 $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node;
218 # the standard word-by-word code will happen next
220 # A sub-heading. Define the keyword and allocate a section number.
222 $xref = "section-$cnum.$hnum.$snum";
223 $pflags = "subh $cnum.$hnum.$snum :$xref";
224 die "badly formatted subheading: $_\n" if !/^\\S{([^}]*)}\s*(.*)$/;
225 $refs{$1} = "section $cnum.$hnum.$snum";
226 $node = "Section $cnum.$hnum.$snum";
228 $xrefnodes{$node} = $xref; $nodexrefs{$xref} = $node;
231 # the standard word-by-word code will happen next
234 die "badly formatted index rewrite: $_\n" if !/^\\IR{([^}]*)}\s*(.*)$/;
237 # the standard word-by-word code will happen next
240 die "badly formatted index alias: $_\n" if !/^\\IA{([^}]*)}{([^}]*)}\s*$/;
242 return; # avoid word-by-word code
245 die "badly formed metadata: $_\n" if !/^\\M{([^}]*)}{([^}]*)}\s*$/;
247 return; # avoid word-by-word code
249 # A bulleted paragraph. Strip off the initial \b and let the
250 # word-by-word code take care of the rest.
254 # A normal paragraph. Just set $pflags: the word-by-word code does
259 # The word-by-word code: unless @$pname is already defined (which it
260 # will be in the case of a code paragraph), split the paragraph up
261 # into words and push each on @$pname.
263 # Each thing pushed on @$pname should have a two-character type
264 # code followed by the text.
269 # "es" for first emphasised word in emphasised bit
270 # "e " for emphasised in mid-emphasised-bit
271 # "ee" for last emphasised word in emphasised bit
272 # "eo" for single (only) emphasised word
275 # "kK" for capitalised cross-ref
277 # "wc" for code-type Web link
278 # "x " for beginning of resolved cross-ref; generates no visible output,
279 # and the text is the cross-reference code
280 # "xe" for end of resolved cross-ref; text is same as for "x ".
281 # "i " for point to be indexed: the text is the internal index into the
285 s/^\s*//, push @
$pname, "sp" if /^\s/;
286 $indexing = $qindex = 0;
287 if (/^(\\[iI])?\\c/) {
288 $qindex = 1 if $1 eq "\\I";
289 $indexing = 1, s/^\\[iI]// if $1;
291 die "badly formatted \\c: \\c$_\n" if !/{(([^\\}]|\\.)*)}(.*)$/;
298 (push @
$pname,"i"),$lastp = $#$pname if $indexing;
299 push @
$pname,"c $w" if !$qindex;
300 $$pname[$lastp] = &addidx
($node, $w, "c $w") if $indexing;
301 } elsif (/^\\[iIe]/) {
304 $qindex = 1 if $1 eq "\\I";
305 $indexing = 1, $type = "\\i" if $1;
306 $emph = 1, $type = "\\e" if $2;
307 s/^(\\[iI])?(\\e?)//;
308 die "badly formatted $type: $type$_\n" if !/{(([^\\}]|\\.)*)}(.*)$/;
315 $t = $emph ?
"es" : "n ";
317 (push @
$pname,"i"),$lastp = $#$pname if $indexing;
318 foreach $i (split /\s+/,$w) { # \e and \i can be multiple words
319 push @
$pname,"$t$i","sp" if !$qindex;
320 ($ii=$i) =~ tr/A-Z/a-z/, push @ientry,"n $ii","sp" if $indexing;
321 $t = $emph ?
"e " : "n ";
323 $w =~ tr/A-Z/a-z/, pop @ientry if $indexing;
324 $$pname[$lastp] = &addidx
($node, $w, @ientry) if $indexing;
325 pop @
$pname if !$qindex; # remove final space
326 if (substr($$pname[$#$pname],0,2) eq "es" && !$qindex) {
327 substr($$pname[$#$pname],0,2) = "eo";
328 } elsif ($emph && !$qindex) {
329 substr($$pname[$#$pname],0,2) = "ee";
331 } elsif (/^\\[kK]/) {
335 die "badly formatted \\k: \\c$_\n" if !/{([^}]*)}(.*)$/;
340 die "badly formatted \\W: \\W$_\n"
341 if !/{([^}]*)}(\\i)?(\\c)?{(([^\\}]|\\.)*)}(.*)$/;
346 $t = "wc" if $3 eq "\\c";
352 (push @
$pname,"i"),$lastp = $#$pname if $indexing;
353 push @
$pname,"$t<$l>$w";
354 $$pname[$lastp] = &addidx
($node, $w, "c $w") if $indexing;
356 die "what the hell? $_\n" if !/^(([^\s\\\-]|\\[\\{}\-])*-?)(.*)$/;
357 die "painful death! $_\n" if !length $1;
371 if ($irewrite ne undef) {
372 &addidx
(undef, $irewrite, @
$pname);
375 push @pnames, $pname;
376 push @pflags, $pflags;
382 my ($node, $text, @ientry) = @_;
383 $text = $idxalias{$text} || $text;
384 if ($node eq undef || !$idxmap{$text}) {
386 $idxmap{$text} = $ientry;
390 $idxnodes{$node,$text} = 1;
396 my $iitem, $ientry, $i, $piitem, $pcval, $cval, $clrcval;
398 @itags = map { # get back the original data as the 1st elt of each list
400 } sort { # compare auxiliary (non-first) elements of lists
401 $a->[1] cmp $b->[1] ||
402 $a->[2] cmp $b->[2] ||
404 } map { # transform array into list of 3-element lists
405 my $ientry = $idxmap{$_};
406 my $a = substr($$ientry[0],2);
408 [$_, uc($a), substr($$ientry[0],0,2)]
411 # Having done that, check for comma-hood.
413 foreach $iitem (@itags) {
414 $ientry = $idxmap{$iitem};
417 FL
:for ($i=0; $i <= $#$ientry; $i++) {
418 if ($$ientry[$i] =~ /^(n .*,)(.*)/) {
420 splice @
$ientry,$i+1,0,"n $2" if length $2;
421 $commapos{$iitem} = $i+1;
422 $cval = join("\002", @
$ientry[0..$i]);
427 $cval = undef if $clrcval;
428 $commanext{$iitem} = $commaafter{$piitem} = 1
429 if $cval and ($cval eq $pcval);
435 my $iitem,$ientry,$w,$ww,$foo,$node;
436 open INDEXDIAG
,">index.diag";
437 foreach $iitem (@itags) {
438 $ientry = $idxmap{$iitem};
439 print INDEXDIAG
"<$iitem> ";
440 foreach $w (@
$ientry) {
442 print INDEXDIAG
$ww unless $ww eq "\001";
446 foreach $node (@nodes) {
447 (print INDEXDIAG
$foo,$node), $foo = ", " if $idxnodes{$node,$iitem};
449 print INDEXDIAG
"\n";
455 my $pname, $p, $i, $j, $k, $caps, @repl;
457 for ($p=0; $p<=$#pnames; $p++) {
458 next if $pflags[$p] eq "code";
459 $pname = $pnames[$p];
460 for ($i=$#$pname; $i >= 0; $i--) {
461 if ($$pname[$i] =~ /^k/) {
463 $caps = ($k =~ /^kK/);
466 die "undefined keyword `$k'\n" unless $repl;
467 substr($repl,0,1) =~ tr/a-z/A-Z/ if $caps;
469 push @repl,"x $xrefs{$k}";
470 foreach $j (split /\s+/,$repl) {
474 pop @repl; # remove final space
475 push @repl,"xe$xrefs{$k}";
476 splice @
$pname,$i,1,@repl;
483 # This is called from the top level, so I won't bother using
487 print "writing file...";
488 open TEXT
,">nasmdoc.txt";
492 $title = "The Netwide Assembler: NASM";
493 $spaces = ' ' x
((75-(length $title))/2);
494 ($underscore = $title) =~ s/./=/g;
495 print "$spaces$title\n$spaces$underscore\n";
497 for ($para = 0; $para <= $#pnames; $para++) {
498 $pname = $pnames[$para];
499 $pflags = $pflags[$para];
500 $ptype = substr($pflags,0,4);
502 print "\n"; # always one of these before a new paragraph
504 if ($ptype eq "chap") {
505 # Chapter heading. "Chapter N: Title" followed by a line of
507 $pflags =~ /chap (.*) :(.*)/;
508 $title = "Chapter $1: ";
509 foreach $i (@
$pname) {
511 $title .= $ww unless $ww eq "\001";
516 } elsif ($ptype eq "appn") {
517 # Appendix heading. "Appendix N: Title" followed by a line of
519 $pflags =~ /appn (.*) :(.*)/;
520 $title = "Appendix $1: ";
521 foreach $i (@
$pname) {
523 $title .= $ww unless $ww eq "\001";
528 } elsif ($ptype eq "head" || $ptype eq "subh") {
529 # Heading or subheading. Just a number and some text.
530 $pflags =~ /.... (.*) :(.*)/;
531 $title = sprintf "%6s ", $1;
532 foreach $i (@
$pname) {
534 $title .= $ww unless $ww eq "\001";
537 } elsif ($ptype eq "code") {
538 # Code paragraph. Emit each line with a seven character indent.
539 foreach $i (@
$pname) {
540 warn "code line longer than 68 chars: $i\n" if length $i > 68;
541 print ' 'x7
, $i, "\n";
543 } elsif ($ptype eq "bull" || $ptype eq "norm") {
544 # Ordinary paragraph, optionally bulleted. We wrap, with ragged
545 # 75-char right margin and either 7 or 11 char left margin
546 # depending on bullets.
547 if ($ptype eq "bull") {
548 $line = ' 'x7
. '(*) ';
551 $line = $next = ' 'x7
;
556 do { $w = &word_txt
(shift @a) } while $w eq "\001"; # nasty hack
558 if ($wprev =~ /-$/ || $w eq ' ' || $w eq '' || $w eq undef) {
559 if (length ($line . $wd) > 75) {
560 $line =~ s/\s*$//; # trim trailing spaces
563 $wd =~ s/^\s*//; # trim leading spaces
569 } while ($w ne '' && $w ne undef);
571 $line =~ s/\s*$//; # trim trailing spaces
586 return undef if $w eq '' || $w eq undef;
587 $wtype = substr($w,0,2);
588 $wmajt = substr($wtype,0,1);
590 $w =~ s/<.*>// if $wmajt eq "w"; # remove web links
591 if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") {
593 } elsif ($wtype eq "sp") {
595 } elsif ($wtype eq "da") {
597 } elsif ($wmajt eq "c" || $wtype eq "wc") {
599 } elsif ($wtype eq "es") {
601 } elsif ($wtype eq "ee") {
603 } elsif ($wtype eq "eo") {
605 } elsif ($wmajt eq "x" || $wmajt eq "i") {
608 die "panic in word_txt: $wtype$w\n";
613 # This is called from the top level, so I won't bother using
616 # Write contents file. Just the preamble, then a menu of links to the
617 # separate chapter files and the nodes therein.
618 print "writing contents file...";
619 open TEXT
,">nasmdoc0.html";
622 print "<p>This manual documents NASM, the Netwide Assembler: an assembler\n";
623 print "targetting the Intel x86 series of processors, with portable source.\n";
625 for ($node = $tstruct_next{'Top'}; $node; $node = $tstruct_next{$node}) {
626 if ($tstruct_level{$node} == 1) {
627 # Invent a file name.
628 ($number = lc($xrefnodes{$node})) =~ s/.*-//;
629 $fname="nasmdocx.html";
630 substr($fname,8 - length $number, length $number) = $number;
631 $html_fnames{$node} = $fname;
635 # Use the preceding filename plus a marker point.
636 $link = $fname . "#$xrefnodes{$node}";
639 $pname = $tstruct_pname{$node};
640 foreach $i (@
$pname) {
641 $ww = &word_html
($i);
642 $title .= $ww unless $ww eq "\001";
644 print "<a href=\"$link\">$title</a><br>\n";
646 print "<p><a href=\"nasmdoci.html\">Index</a>\n";
647 print "</body></html>\n";
651 # Open a null file, to ensure output (eg random &html_jumppoints calls)
653 print "writing chapter files...";
654 open TEXT
,">/dev/null";
660 for ($para = 0; $para <= $#pnames; $para++) {
661 $pname = $pnames[$para];
662 $pflags = $pflags[$para];
663 $ptype = substr($pflags,0,4);
665 $in_list = 0, print "</ul>\n" if $in_list && $ptype ne "bull";
666 if ($ptype eq "chap") {
667 # Chapter heading. Begin a new file.
668 $pflags =~ /chap (.*) :(.*)/;
669 $title = "Chapter $1: ";
671 &html_jumppoints
; print "</body></html>\n"; select STDOUT
; close TEXT
;
672 $html_lastf = $html_fnames{$chapternode};
673 $chapternode = $nodexrefs{$xref};
674 $html_nextf = $html_fnames{$tstruct_mnext{$chapternode}};
675 open TEXT
,">$html_fnames{$chapternode}"; select TEXT
; &html_preamble
(1);
676 foreach $i (@
$pname) {
677 $ww = &word_html
($i);
678 $title .= $ww unless $ww eq "\001";
680 $h = "<h2><a name=\"$xref\">$title</a></h2>\n";
681 print $h; print FULL
$h;
682 } elsif ($ptype eq "appn") {
683 # Appendix heading. Begin a new file.
684 $pflags =~ /appn (.*) :(.*)/;
685 $title = "Appendix $1: ";
687 &html_jumppoints
; print "</body></html>\n"; select STDOUT
; close TEXT
;
688 $html_lastf = $html_fnames{$chapternode};
689 $chapternode = $nodexrefs{$xref};
690 $html_nextf = $html_fnames{$tstruct_mnext{$chapternode}};
691 open TEXT
,">$html_fnames{$chapternode}"; select TEXT
; &html_preamble
(1);
692 foreach $i (@
$pname) {
693 $ww = &word_html
($i);
694 $title .= $ww unless $ww eq "\001";
696 print "<h2><a name=\"$xref\">$title</a></h2>\n";
697 } elsif ($ptype eq "head" || $ptype eq "subh") {
698 # Heading or subheading.
699 $pflags =~ /.... (.*) :(.*)/;
700 $hdr = ($ptype eq "subh" ?
"h4" : "h3");
703 foreach $i (@
$pname) {
704 $ww = &word_html
($i);
705 $title .= $ww unless $ww eq "\001";
707 print "<$hdr><a name=\"$xref\">$title</a></$hdr>\n";
708 } elsif ($ptype eq "code") {
711 foreach $i (@
$pname) {
719 } elsif ($ptype eq "bull" || $ptype eq "norm") {
720 # Ordinary paragraph, optionally bulleted. We wrap, with ragged
721 # 75-char right margin and either 7 or 11 char left margin
722 # depending on bullets.
723 if ($ptype eq "bull") {
724 $in_list = 1, print "<ul>\n" unless $in_list;
732 do { $w = &word_html
(shift @a) } while $w eq "\001"; # nasty hack
734 if ($w eq ' ' || $w eq '' || $w eq undef) {
735 if (length ($line . $wd) > 75) {
736 $line =~ s/\s*$//; # trim trailing spaces
739 $wd =~ s/^\s*//; # trim leading spaces
745 } while ($w ne '' && $w ne undef);
747 $line =~ s/\s*$//; # trim trailing spaces
753 # Close whichever file was open.
755 print "</body></html>\n";
759 print "\n writing index file...";
760 open TEXT
,">nasmdoci.html";
763 print "<p align=center><a href=\"nasmdoc0.html\">Contents</a>\n";
766 print "<p align=center><a href=\"nasmdoc0.html\">Contents</a>\n";
767 print "</body></html>\n";
773 print "<html><head><title>NASM Manual</title></head>\n";
774 print "<body><h1 align=center>The Netwide Assembler: NASM</h1>\n\n";
775 &html_jumppoints
if $_[0];
778 sub html_jumppoints
{
779 print "<p align=center>";
780 print "<a href=\"$html_nextf\">Next Chapter</a> |\n" if $html_nextf;
781 print "<a href=\"$html_lastf\">Previous Chapter</a> |\n" if $html_lastf;
782 print "<a href=\"nasmdoc0.html\">Contents</a> |\n";
783 print "<a href=\"nasmdoci.html\">Index</a>\n";
787 my $itag, $a, @ientry, $sep, $w, $wd, $wprev, $line;
790 foreach $itag (@itags) {
791 $ientry = $idxmap{$itag};
795 foreach $node (@nodes) {
796 next if !$idxnodes{$node,$itag};
797 push @a, "n ," if $sep;
798 push @a, "sp", "x $xrefnodes{$node}", "n $node", "xe$xrefnodes{$node}";
803 do { $w = &word_html
(shift @a) } while $w eq "\001"; # nasty hack
805 if ($w eq ' ' || $w eq '' || $w eq undef) {
806 if (length ($line . $wd) > 75) {
807 $line =~ s/\s*$//; # trim trailing spaces
810 $wd =~ s/^\s*//; # trim leading spaces
816 } while ($w ne '' && $w ne undef);
818 $line =~ s/\s*$//; # trim trailing spaces
827 my $wtype, $wmajt, $pfx, $sfx;
829 return undef if $w eq '' || $w eq undef;
831 $wtype = substr($w,0,2);
832 $wmajt = substr($wtype,0,1);
835 $pfx = "<a href=\"$1\">", $sfx = "</a>", $w = $2
836 if $wmajt eq "w" && $w =~ /^<(.*)>(.*)$/;
840 if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") {
841 return $pfx . $w . $sfx;
842 } elsif ($wtype eq "sp") {
844 } elsif ($wtype eq "da") {
845 return '-'; # sadly, en-dashes are non-standard in HTML
846 } elsif ($wmajt eq "c" || $wtype eq "wc") {
847 return $pfx . "<code><nobr>${w}</nobr></code>" . $sfx;
848 } elsif ($wtype eq "es") {
850 } elsif ($wtype eq "ee") {
852 } elsif ($wtype eq "eo") {
853 return "<em>${w}</em>";
854 } elsif ($wtype eq "x ") {
855 # Magic: we must resolve the cross reference into file and marker
856 # parts, then dispose of the file part if it's us, and dispose of
857 # the marker part if the cross reference describes the top node of
859 my $node = $nodexrefs{$w}; # find the node we're aiming at
860 my $level = $tstruct_level{$node}; # and its level
861 my $up = $node, $uplev = $level-1;
862 $up = $tstruct_up{$up} while $uplev--; # get top node of containing file
863 my $file = ($up ne $chapternode) ?
$html_fnames{$up} : "";
864 my $marker = ($level == 1 and $file) ?
"" : "#$w";
865 return "<a href=\"$file$marker\">";
866 } elsif ($wtype eq "xe") {
868 } elsif ($wmajt eq "i") {
871 die "panic in word_html: $wtype$w\n";
881 sub ps_write_bookmarks
{
886 my $ref, $pref, $i, $title;
888 for ($para = 0; $para <= $#pnames; $para++) {
889 my $pname = $pnames[$para];
890 my $pflags = $pflags[$para];
891 my $ptype = substr($pflags,0,4);
893 if ($ptype eq "chap" || $ptype eq "appn") {
894 # Chapter/appendix heading. "Chapter N: Title" followed by a line of
897 $pflags =~ /(chap|appn) (.*) :(.*)/;
900 foreach $i (@
$pname) {
901 $title .= &word_ps_title
($i);
903 $titles{$ref} = $title;
905 } elsif ($ptype eq "head" || $ptype eq "subh") {
906 # Heading/subheading. Just a number and some text.
907 $pflags =~ /.... (.*) :(.*)/;
909 $ref =~ /^(n[0-9A-Za-z_]+)\_[0-9A-Za-z]+$/;
913 foreach $i (@
$pname) {
914 $title .= &word_ps_title
($i);
916 $titles{$ref} = $title;
922 # Now we should have enough data to generate the bookmarks
923 print "[/Title (Contents) /Dest /nContents /OUT pdfmark";
924 foreach $i ( @reflist ) {
925 print '[/Title (', $titles{$i}, ")\n";
926 print '/Count -', $nchildren{$i}, ' ' if ( $nchildren{$i} );
927 print "/Dest /$i /OUT pdfmark\n";
929 print "[/Title (Index) /Dest /nIndex /OUT pdfmark\n";
933 # This is called from the top level, so I won't bother using
936 # First, set up the font metric arrays.
939 # First stage: reprocess the source arrays into a list of
940 # lines, each of which is a list of word-strings, each of
941 # which has a single-letter font code followed by text.
942 # Each line also has an associated type, which will be
943 # used for final alignment and font selection and things.
949 # ' ' == space (no following text required)
950 # '-' == dash (no following text required)
953 # chap == Chapter or appendix heading.
954 # head == Major heading.
955 # subh == Sub-heading.
956 # Ccha == Contents entry for a chapter.
957 # Chea == Contents entry for a heading.
958 # Csub == Contents entry for a subheading.
959 # cone == Code paragraph with just this one line on it.
960 # cbeg == First line of multi-line code paragraph.
961 # cbdy == Interior line of multi-line code paragraph.
962 # cend == Final line of multi-line code paragraph.
963 # none == Normal paragraph with just this one line on it.
964 # nbeg == First line of multi-line normal paragraph.
965 # nbdy == Interior line of multi-line normal paragraph.
966 # nend == Final line of multi-line normal paragraph.
967 # bone == Bulleted paragraph with just this one line on it.
968 # bbeg == First line of multi-line bulleted paragraph.
969 # bbdy == Interior line of multi-line bulleted paragraph.
970 # bend == Final line of multi-line bulleted paragraph.
971 print "line-breaks...";
972 $lname = "psline000000";
973 $lnamei = "idx" . $lname;
974 @lnames = @ltypes = ();
976 $linewidth = 468; # ADJUSTABLE: width of a normal text line
977 $bulletadj = 12; # ADJUSTABLE: space for a bullet
979 for ($para = 0; $para <= $#pnames; $para++) {
980 $pname = $pnames[$para];
981 $pflags = $pflags[$para];
982 $ptype = substr($pflags,0,4);
984 # New paragraph _ergo_ new line.
986 @lindex = (); # list of index tags referenced to this line
988 if ($ptype eq "chap") {
989 # Chapter heading. "Chapter N: Title" followed by a line of
991 $pflags =~ /chap (.*) :(.*)/;
992 push @line, "B".&ref_ps
($1), "nChapter", " ", "n$1:", " ";
993 foreach $i (@
$pname) {
995 push @line, $ww unless $ww eq "x";
997 @
$lname = @line; @
$lnamei = @lindex;
998 push @lnames, $lname++;
999 $lnamei = "idx" . $lname;
1000 push @ltypes, "chap";
1001 } elsif ($ptype eq "appn") {
1002 # Appendix heading. "Appendix N: Title" followed by a line of
1004 $pflags =~ /appn (.*) :(.*)/;
1005 push @line, "B".&ref_ps
($1), "nAppendix", " ", "n$1:", " ";
1006 foreach $i (@
$pname) {
1008 push @line, $ww unless $ww eq "x";
1010 @
$lname = @line; @
$lnamei = @lindex;
1011 push @lnames, $lname++;
1012 $lnamei = "idx" . $lname;
1013 push @ltypes, "chap";
1014 } elsif ($ptype eq "head") {
1015 # Heading. Just a number and some text.
1016 $pflags =~ /.... (.*) :(.*)/;
1017 push @line, "B".&ref_ps
($1), "n$1";
1018 foreach $i (@
$pname) {
1020 push @line, $ww unless $ww eq "x";
1022 @
$lname = @line; @
$lnamei = @lindex;
1023 push @lnames, $lname++;
1024 $lnamei = "idx" . $lname;
1025 push @ltypes, $ptype;
1026 } elsif ($ptype eq "subh") {
1027 # Subheading. Just a number and some text.
1028 $pflags =~ /subh (.*) :(.*)/;
1029 push @line, "B".&ref_ps
($1), "n$1";
1030 foreach $i (@
$pname) {
1031 push @line, &word_ps
($i);
1033 @
$lname = @line; @
$lnamei = @lindex;
1034 push @lnames, $lname++;
1035 $lnamei = "idx" . $lname;
1036 push @ltypes, "subh";
1037 } elsif ($ptype eq "code") {
1038 # Code paragraph. Emit lines one at a time.
1040 foreach $i (@
$pname) {
1042 push @lnames, $lname++;
1043 $lnamei = "idx" . $lname;
1044 push @ltypes, $type;
1047 $ltypes[$#ltypes] = ($ltypes[$#ltypes] eq "cbeg" ?
"cone" : "cend");
1048 } elsif ($ptype eq "bull" || $ptype eq "norm") {
1049 # Ordinary paragraph, optionally bulleted. We wrap, with ragged
1050 # 75-char right margin and either 7 or 11 char left margin
1051 # depending on bullets.
1052 if ($ptype eq "bull") {
1053 $width = $linewidth - $bulletadj;
1054 $type = $begtype = "bbeg";
1059 $width = $linewidth;
1060 $type = $begtype = "nbeg";
1070 do { $w = &word_ps
(shift @a) } while ($w eq "x");
1071 push @wd, $wprev if $wprev;
1072 if ($wprev =~ /^n.*-$/ || $w eq ' ' || $w eq '' || $w eq undef) {
1073 $wdlen = &len_ps
(@wd);
1074 if ($linelen + $wdlen > $width) {
1075 pop @line while $line[$#line] eq ' '; # trim trailing spaces
1076 @
$lname = @line; @
$lnamei = @lindex;
1077 push @lnames, $lname++;
1078 $lnamei = "idx" . $lname;
1079 push @ltypes, $type;
1081 @line = @lindex = ();
1083 shift @wd while $wd[0] eq ' '; # trim leading spaces
1090 } while ($w ne '' && $w ne undef);
1092 pop @line while $line[$#line] eq ' '; # trim trailing spaces
1093 @
$lname = @line; @
$lnamei = @lindex;
1094 push @lnames, $lname++;
1095 $lnamei = "idx" . $lname;
1096 push @ltypes, $type;
1100 ($ltypes[$#ltypes] eq $begtype ?
$onetype : $endtype);
1104 # We've now processed the document source into lines. Before we
1105 # go on and do the page breaking, we'll fabricate a table of contents,
1106 # line by line, and then after doing page breaks we'll go back and
1107 # insert the page numbers into the contents entries.
1108 print "building contents...";
1109 @clnames = @cltypes = ();
1110 $clname = "pscont000000";
1111 @
$clname = ("BnContents", "nContents"); # "chapter heading" for TOC
1112 push @clnames,$clname++;
1113 push @cltypes,"chap";
1114 for ($i=0; $i<=$#lnames; $i++) {
1115 $lname = $lnames[$i];
1116 if ($ltypes[$i] =~ /^(chap|head|subh)/) {
1118 splice @
$clname,2,0," " if ($ltypes[$i] !~ /chap/);
1119 push @
$clname,$i; # placeholder for page number
1120 push @clnames,$clname++;
1121 push @cltypes,"C" . substr($ltypes[$i],0,3);
1124 @
$clname = ("BnIndex", "nIndex"); # contents entry for Index
1125 push @
$clname,$i; # placeholder for page number
1126 $idx_clname = $clname;
1127 push @clnames,$clname++;
1128 push @cltypes,"Ccha";
1129 $contlen = $#clnames + 1;
1130 unshift @lnames,@clnames;
1131 unshift @ltypes,@cltypes;
1133 # Second stage: now we have a list of lines, break them into pages.
1134 # We do this by means of adding a third array in parallel with
1135 # @lnames and @ltypes, called @lpages, in which we store the page
1136 # number that each line resides on. We also add @ycoord which
1137 # stores the vertical position of each line on the page.
1139 # Page breaks may not come after line-types:
1140 # chap head subh cbeg nbeg bbeg
1141 # and may not come before line-types:
1143 # They are forced before line-types:
1145 print "page-breaks...";
1146 $pmax = 600; # ADJUSTABLE: maximum length of a page in points
1147 $textht = 11; # ADJUSTABLE: height of a normal line in points
1148 $spacing = 6; # ADJUSTABLE: space between paragraphs, in points
1149 $headht = 14; # ADJUSTABLE: height of a major heading in points
1150 $subht = 12; # ADJUSTABLE: height of a sub-heading in points
1151 $pstart = 0; # start line of current page
1152 $plen = 0; # current length of current page
1153 $pnum = 1; # number of current page
1154 $bpt = -1; # last feasible break point
1155 $i = 0; # line number
1156 while ($i <= $#lnames) {
1157 $lname = $lnames[$i];
1158 # Add the height of this line (computed the last time we went round
1159 # the loop, unless we're a chapter heading in which case we do it
1160 # now) to the length of the current page. Also, _put_ this line on
1161 # the current page, and allocate it a y-coordinate.
1162 if ($ltypes[$i] =~ /^chap$/) {
1163 $pnum += 1 - ($pnum & 1); # advance to odd numbered page if necessary
1164 $plen = 100; # ADJUSTABLE: space taken up by a chapter heading
1165 $ycoord[$i] = 0; # chapter heading: y-coord doesn't matter
1167 $ycoord[$i] = $plen + $space;
1168 $plen += $space + $ht;
1170 # See if we can break after this line.
1171 $bpt = $i if $ltypes[$i] !~ /^chap|head|subh|cbeg|nbeg|bbeg$/ &&
1172 $ltypes[$i+1] !~ /^cend|nend|bend$/;
1173 # Assume, to start with, that we don't break after this line.
1175 # See if a break is forced.
1176 $break = 1, $bpt = $i if $ltypes[$i+1] eq "chap" || !$ltypes[$i+1];
1177 # Otherwise, compute the height of the next line, and break if
1178 # it would make this page too long.
1179 $ht = $textht, $space = 0 if $ltypes[$i+1] =~ /^[nbc](bdy|end)$/;
1180 $ht = $textht, $space = $spacing if $ltypes[$i+1] =~ /^[nbc](one|beg)$/;
1181 $ht = $textht, $space = $spacing if $ltypes[$i+1] =~ /^C/;
1182 $ht = $subht, $space = $spacing if $ltypes[$i+1] eq "subh";
1183 $ht = $headht, $space = $spacing if $ltypes[$i+1] eq "head";
1184 $break = 1 if $plen + $space + $ht > $pmax;
1185 # Now, if we're breaking, assign page number $pnum to all lines up
1186 # to $bpt, set $i == $bpt+1, and zero $space since we are at the
1187 # start of a new page and don't want leading space.
1189 die "no feasible break point at all on page $pnum\n" if $bpt == -1;
1190 for ($j = $pstart; $j <= $bpt; $j++) {
1191 $lnamei = "idx" . $lnames[$j];
1192 foreach $k (@
$lnamei) {
1193 ${$psidxpp{$k}}{$pnum} = 1;
1195 $lpages[$j] = $pnum;
1207 # Now fix up the TOC with page numbers.
1208 print "\n fixing up contents...";
1209 for ($i=0; $i<=$#lnames; $i++) {
1210 $lname = $lnames[$i];
1211 if ($ltypes[$i] =~ /^C/) {
1213 push @
$lname, "n" . $lpages[$j+$contlen];
1217 # Having got page numbers for most stuff, generate an index.
1218 print "building index...";
1222 foreach $k (@itags) {
1225 @idxentry = @
{$idxmap{$k}};
1226 if ($commaafter{$k} and !$commanext{$k}) {
1227 # This line is a null line beginning a multiple entry. We must
1228 # output the prefix on a line by itself.
1230 @idxhead = splice @idxentry,0,$commapos{$k};
1232 foreach $i (@idxhead) {
1234 push @line, $ww unless $ww eq "x";
1236 &ps_idxout
("index",\
@line,[]);
1240 $cmd = "iindex", splice @idxentry,0,$commapos{$k} if $commanext{$k};
1241 foreach $i (@idxentry) {
1243 push @line, $ww unless $ww eq "x";
1245 $len = $iwid - $sep - &len_ps
(@line);
1246 warn "text for index tag `%s' is longer than one index line!\n"
1249 $inums = join(',',sort { $a <=> $b } keys %{$psidxpp{$k}});
1250 while (length $inums) {
1251 $inums =~ /^([^,]+)(,?)(.*)$/;
1252 $inums = $3, $inumc = $2; $inum = $1;
1253 @pnum = (" ", "Bp$inum", "n$inum", "E");
1254 push(@pnum, "n$inumc") if ( $inumc ne '' );
1255 $pnumlen = &len_ps
(@pnum);
1256 if ($pnumlen > $len) {
1257 &ps_idxout
($cmd,\
@line,\
@pp);
1261 $len = $iwid - $sep;
1266 &ps_idxout
($cmd,\
@line,\
@pp) if (length @pp);
1267 $l1 = &len_ps
(@line);
1270 $$idx_clname[$#$idx_clname] = "n" . $pnum; # fix up TOC entry for index
1272 print "writing file...";
1273 open PS
,">nasmdoc.ps";
1277 &ps_write_bookmarks
;
1278 for ($i=0; $i<=$#lnames; $i++) {
1279 &ps_throw_pg
($page,$lpages[$i]) if $page != $lpages[$i];
1280 $page = $lpages[$i];
1281 &ps_out_line
($ycoord[$i],$ltypes[$i],$lnames[$i]);
1284 while ($i <= $#psindex) {
1285 &ps_throw_pg
($page, $pnum) if $page != $pnum;
1288 $ypos = 100, &ps_out_line
(0, "chap", ["BnIndex", "nIndex"]) if !$i;
1289 $lines = ($pmax - $ypos) / $textht;
1290 my $col; # ps_out_line hits this variable
1291 PAGE
:for ($col = 1; $col <= 2; $col++) {
1292 $y = $ypos; $l = $lines;
1293 COL
: while ($l > 0) {
1295 $j++ while $psindex[$j] and ($psindex[$j][3] == 0); # find next break
1296 last COL
if $j-$i > $l or $i > $#psindex;
1298 &ps_out_line
($y, $psindex[$i][0] eq "index" ?
"idl$col" : "ldl$col",
1300 &ps_out_line
($y,"idr$col",$psindex[$i][2]);
1306 last PAGE
if $i > $#psindex;
1315 my ($cmd, $left, $right) = @_;
1318 if ($#psindex >= 0) and ( ($#$left < 0) or ($cmd eq "iindex") );
1319 push @psindex,[$cmd,[@
$left],[@
$right],$break];
1325 /nf /Times-Roman findfont 11 scalefont def
1326 /ef /Times-Italic findfont 11 scalefont def
1327 /cf /Courier findfont 11 scalefont def
1328 /nc /Helvetica-Bold findfont 18 scalefont def
1329 /ec /Helvetica-Oblique findfont 18 scalefont def
1330 /cc /Courier-Bold findfont 18 scalefont def
1331 /nh /Helvetica-Bold findfont 14 scalefont def
1332 /eh /Helvetica-Oblique findfont 14 scalefont def
1333 /ch /Courier-Bold findfont 14 scalefont def
1334 /ns /Helvetica-Bold findfont 12 scalefont def
1335 /es /Helvetica-Oblique findfont 12 scalefont def
1336 /cs /Courier-Bold findfont 12 scalefont def
1337 /n 16#6E def /e 16#65 def /c 16#63 def
1338 /B 16#42 def /E 16#45 def /D 16#44 def
1339 /min { 2 copy gt { exch } if pop } def
1340 /max { 2 copy lt { exch } if pop } def
1349 /lktarget exch cvn def
1353 gsave dup true charpath pathbbox grestore
1361 lkury max /lkury exch def
1362 lkurx max /lkurx exch def
1363 lklly min /lklly exch def
1364 lkllx min /lkllx exch def
1370 [/Rect [ lkllx lklly lkurx lkury ]
1371 /Color [ 1.0 0.0 0.0 ]
1379 /lkdest exch cvn def
1381 /View [ /XYZ currentpoint 0 ]
1387 pop dup length 1 sub 1 exch getinterval linkbegin
1392 dup length 1 sub 1 exch getinterval linkdest
1397 550 50 moveto ns setfont dup stringwidth pop neg 0 rmoveto show
1399 /pageeven { 50 50 moveto ns setfont show } def
1401 dup length 1 sub 1 exch getinterval linkdest
1406 dup length 1 sub 1 exch getinterval
1409 dup n eq {pop nc setfont} {
1410 e eq {ec setfont} {cc setfont} ifelse
1412 dup length 1 sub 1 exch getinterval show
1414 0 setlinecap 3 setlinewidth
1415 newpath 100 610 moveto 468 0 rlineto stroke
1418 686 exch sub /y exch def /a exch def
1421 a 1 get dup length 1 sub 1 exch getinterval
1422 nh setfont dup stringwidth pop neg 0 rmoveto show
1424 a dup length 2 sub 2 exch getinterval {
1427 dup n eq {pop nh setfont} {
1428 e eq {eh setfont} {ch setfont} ifelse
1430 s s length 1 sub 1 exch getinterval show
1434 688 exch sub /y exch def /a exch def
1437 a 1 get dup length 1 sub 1 exch getinterval
1438 ns setfont dup stringwidth pop neg 0 rmoveto show
1440 a dup length 2 sub 2 exch getinterval {
1443 dup n eq {pop ns setfont} {
1444 e eq {es setfont} {cs setfont} ifelse
1446 s s length 1 sub 1 exch getinterval show
1450 568 exch sub exch 689 exch sub moveto
1457 dup n eq {pop nf setfont} {
1458 e eq {ef setfont} {cf setfont} ifelse
1460 s s length 1 sub 1 exch getinterval linkshow
1461 s sp eq {j 0 rmoveto} if
1465 /contents { /w exch def /y exch def /a exch def
1467 a a length 1 sub get dup length 1 sub 1 exch getinterval
1469 nf setfont 568 ss stringwidth pop sub /ex exch def
1470 a 0 a length 1 sub getinterval y w 0 disp
1471 /sx currentpoint pop def nf setfont
1472 100 10 568 { /i exch def
1473 i 5 sub sx gt i 5 add ex lt and {
1474 i yy moveto (.) linkshow
1477 ex yy moveto ss linkshow
1480 /just { /w exch def /y exch def /a exch def
1481 /jj w def /spaces 0 def
1485 dup n eq {pop nf setfont} {
1486 e eq {ef setfont} {cf setfont} ifelse
1488 s s length 1 sub 1 exch getinterval stringwidth pop
1489 jj exch sub /jj exch def
1490 s sp eq {/spaces spaces 1 add def} if
1492 a y w jj spaces spaces 0 eq {pop pop 0} {div} ifelse disp
1494 /idl { 468 exch sub 0 disp } def
1495 /ldl { 436 exch sub 0 disp } def
1496 /idr { 222 add 468 exch sub /x exch def /y exch def /a exch def
1503 dup n eq {pop nf setfont} {
1504 e eq {ef setfont} {cf setfont} ifelse
1506 s s length 1 sub 1 exch getinterval stringwidth pop
1514 nf setfont dup 100 exch 689 exch sub moveto (\267) show
1516 [/PageMode /UseOutlines /DOCVIEW pdfmark
1518 print "%!PS-Adobe-3.0\n";
1519 print "%%BoundingBox: 95 95 590 705\n";
1520 print "%%Creator: a nasty Perl script\n";
1521 print "%%DocumentData: Clean7Bit\n";
1522 print "%%Orientation: Portrait\n";
1523 print "%%Pages: $lpages[$#lpages]\n";
1524 print "%%DocumentNeededResources: font Times-Roman Times-Italic\n";
1525 print "%%+ font Helvetica-Bold Courier Courier-Bold\n";
1526 print "%%EndComments\n";
1527 print "%%BeginProlog\n";
1528 # This makes sure non-PDF PostScript interpreters don't choke on
1529 # pdfmarks in the output
1530 print "/pdfmark where\n";
1531 print "{pop} {userdict /pdfmark /cleartomark load put} ifelse\n";
1532 print "%%EndProlog\n";
1533 print "%%BeginSetup\n";
1535 $pshdr =~ s/\s+/ /g;
1536 while ($pshdr =~ /\S/) {
1537 last if length($pshdr) < 72 || $pshdr !~ /^(.{0,72}\S)\s(.*)$/;
1541 print "$pshdr\n" if $pshdr =~ /\S/;
1542 print "%%EndSetup\n";
1543 &ps_initpg
($lpages[0]);
1549 print "%%Trailer\nrestore\n%%EOF\n";
1553 my ($oldpg, $newpg) = @_;
1554 while ($oldpg < $newpg) {
1563 print "%%Page: $pgnum $pgnum\n";
1564 print "%%BeginPageSetup\nsave\n%%EndPageSetup\n";
1565 print "95 705 moveto (p$pgnum) linkdest\n";
1571 print "%%PageTrailer\n($pgnum)pageodd restore showpage\n";
1573 print "%%PageTrailer\n($pgnum)pageeven restore showpage\n";
1578 my ($ypos,$ltype,$lname) = @_;
1583 foreach $c (@
$lname) {#
1584 $c= "n " if $c eq " ";
1585 $c = "n\261" if $c eq "-";
1588 $d .= $1, $c = $2 while $c =~ /^([ -\'\*-\[\]-~]+)(.*)$/;
1590 $d .= "\\$1", $c = $2, next if $c =~ /^([\\\(\)])(.*)$/;
1591 ($d .= sprintf "\\%3o",unpack("C",$1)), $c = $2, next
1592 if $c =~ /^([^ -~])(.*)$/;
1597 $col = 0, print "\n" if $col>0 && $col+length $d > 77;
1601 print "\n" if $col > 60;
1603 if ($ltype =~ /^[nb](beg|bdy)$/) {
1604 printf "%d %s%d just\n",
1605 $ypos, ($ltype eq "bbeg" ?
"bullet " : ""),
1606 ($ltype =~ /^b/ ?
456 : 468);
1607 } elsif ($ltype =~ /^[nb](one|end)$/) {
1608 printf "%d %s%d left\n",
1609 $ypos, ($ltype eq "bone" ?
"bullet " : ""),
1610 ($ltype =~ /^b/ ?
456 : 468);
1611 } elsif ($ltype =~ /^c(one|beg|bdy|end)$/) {
1612 printf "$ypos 468 left\n";
1613 } elsif ($ltype =~ /^C/) {
1615 $wid = 456 if $ltype eq "Chea";
1616 $wid = 444 if $ltype eq "Csub";
1617 printf "$ypos $wid contents\n";
1618 } elsif ($ltype eq "chap") {
1620 } elsif ($ltype eq "head") {
1621 printf "$ypos heading\n";
1622 } elsif ($ltype eq "subh") {
1623 printf "$ypos subhead\n";
1624 } elsif ($ltype =~ /([il]d[lr])([12])/) {
1625 $left = ($2 eq "2" ?
468-222 : 0);
1626 printf "$ypos $left $1\n";
1634 return undef if $w eq '' || $w eq undef;
1636 $wtype = substr($w,0,2);
1637 $wmajt = substr($wtype,0,1);
1639 $w =~ s/<.*>// if $wmajt eq "w"; # remove web links
1640 if ($wmajt eq "n" || $wtype eq "w ") {
1642 } elsif ($wtype eq "sp") {
1644 } elsif ($wtype eq "da") {
1646 } elsif ($wmajt eq "c" || $wtype eq "wc") {
1648 } elsif ($wmajt eq "e") {
1650 } elsif ($wmajt eq "x") {
1652 } elsif ($wtype eq "i ") {
1656 die "panic in word_ps: $wtype$w\n";
1664 return undef if $w eq '' || $w eq undef;
1666 $wtype = substr($w,0,2);
1667 $wmajt = substr($wtype,0,1);
1669 $w =~ s/<.*>// if $wmajt eq "w"; # remove web links
1670 if ($wmajt eq "n" || $wtype eq "w ") {
1672 } elsif ($wtype eq "sp") {
1674 } elsif ($wtype eq "da") {
1676 } elsif ($wmajt eq "c" || $wtype eq "wc") {
1678 } elsif ($wmajt eq "e") {
1680 } elsif ($wmajt eq "x") {
1682 } elsif ($wtype eq "i ") {
1685 die "panic in word_ps_title: $wtype$w\n";
1694 $size = 11/1000; # used only for length calculations
1695 while ($w = shift @line) {
1696 $w = "n " if $w eq " ";
1697 $w = "n\261" if $w eq "-";
1698 $f = substr($w,0,1);
1699 if ( $f !~ /^[BDE]$/ ) {
1700 $f = "timesr" if $f eq "n";
1701 $f = "timesi" if $f eq "e";
1702 $f = "courr" if $f eq "c";
1703 foreach $c (unpack 'C*',substr($w,1)) {
1704 $l += $size * $$f[$c];
1712 # This is called from the top level, so I won't bother using
1716 print "writing file...";
1717 open TEXT
,">nasmdoc.texi";
1721 print "\\input texinfo \@c -*-texinfo-*-\n";
1722 print "\@c \%**start of header\n";
1723 print "\@setfilename ",$metadata{'infofile'},".info\n";
1724 print "\@dircategory ",$metadata{'category'},"\n";
1725 print "\@direntry\n";
1726 printf "* %-28s %s.\n",
1727 sprintf('%s: (%s).', $metadata{'infoname'}, $metadata{'infofile'}),
1728 $metadata{'infotitle'};
1729 print "\@end direntry\n";
1730 print "\@settitle ",$metadata{'title'},"\n";
1731 print "\@setchapternewpage odd\n";
1732 print "\@c \%**end of header\n";
1735 print $metadata{'summary'}, "\n";
1737 print "Copyright ",$metadata{'year'}," ",$metadata{'author'},"\n";
1739 print $metadata{'license'}, "\n";
1740 print "\@end ifinfo\n";
1742 print "\@titlepage\n";
1743 print "\@title ",$metadata{'title'},"\n";
1744 print "\@author ",$metadata{'author'},"\n";
1747 print "\@vskip 0pt plus 1filll\n";
1748 print "Copyright \@copyright{} ",$metadata{'year'},' ',$metadata{'author'},"\n";
1750 print $metadata{'license'}, "\n";
1751 print "\@end titlepage\n";
1753 print "\@node Top, $tstruct_next{'Top'}, (dir), (dir)\n";
1754 print "\@top ",$metadata{'infotitle'},"\n";
1757 print $metadata{'summary'}, "\n";
1758 print "\@end ifinfo\n";
1763 for ($para = 0; $para <= $#pnames; $para++) {
1764 $pname = $pnames[$para];
1765 $pflags = $pflags[$para];
1766 $ptype = substr($pflags,0,4);
1768 $bulleting = 0, print "\@end itemize\n" if $bulleting && $ptype ne "bull";
1769 print "\n"; # always one of these before a new paragraph
1771 if ($ptype eq "chap") {
1772 # Chapter heading. Begin a new node.
1774 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
1775 $pflags =~ /chap (.*) :(.*)/;
1776 $node = "Chapter $1";
1777 $title = "Chapter $1: ";
1778 foreach $i (@
$pname) {
1779 $ww = &word_texi
($i);
1780 $title .= $ww unless $ww eq "\001";
1782 print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},";
1783 print " $tstruct_up{$node}\n\@unnumbered $title\n";
1784 } elsif ($ptype eq "appn") {
1785 # Appendix heading. Begin a new node.
1787 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
1788 $pflags =~ /appn (.*) :(.*)/;
1789 $node = "Appendix $1";
1790 $title = "Appendix $1: ";
1791 foreach $i (@
$pname) {
1792 $ww = &word_texi
($i);
1793 $title .= $ww unless $ww eq "\001";
1795 print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},";
1796 print " $tstruct_up{$node}\n\@unnumbered $title\n";
1797 } elsif ($ptype eq "head" || $ptype eq "subh") {
1798 # Heading or subheading. Begin a new node.
1800 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
1801 $pflags =~ /.... (.*) :(.*)/;
1802 $node = "Section $1";
1804 foreach $i (@
$pname) {
1805 $ww = &word_texi
($i);
1806 $title .= $ww unless $ww eq "\001";
1808 print "\@node $node, $tstruct_next{$node}, $tstruct_prev{$node},";
1809 print " $tstruct_up{$node}\n";
1810 $hdr = ($ptype eq "subh" ?
"\@unnumberedsubsec" : "\@unnumberedsec");
1811 print "$hdr $title\n";
1812 } elsif ($ptype eq "code") {
1813 # Code paragraph. Surround with @example / @end example.
1814 print "\@example\n";
1815 foreach $i (@
$pname) {
1816 warn "code line longer than 68 chars: $i\n" if length $i > 68;
1822 print "\@end example\n";
1823 } elsif ($ptype eq "bull" || $ptype eq "norm") {
1824 # Ordinary paragraph, optionally bulleted. We wrap, FWIW.
1825 if ($ptype eq "bull") {
1826 $bulleting = 1, print "\@itemize \@bullet\n" if !$bulleting;
1833 do { $w = &word_texi
(shift @a); } while $w eq "\001"; # hack
1835 if ($wprev =~ /-$/ || $w eq ' ' || $w eq '' || $w eq undef) {
1836 if (length ($line . $wd) > 75) {
1837 $line =~ s/\s*$//; # trim trailing spaces
1840 $wd =~ s/^\s*//; # trim leading spaces
1846 } while ($w ne '' && $w ne undef);
1847 if ($line =~ /\S/) {
1848 $line =~ s/\s*$//; # trim trailing spaces
1858 print "\n\@contents\n\@bye\n";
1863 # Side effect of this procedure: update global `texiwdlen' to be the length
1864 # in chars of the formatted version of the word.
1869 return undef if $w eq '' || $w eq undef;
1870 $wtype = substr($w,0,2);
1871 $wmajt = substr($wtype,0,1);
1877 $w =~ s/<.*>// if $wmajt eq "w"; # remove web links
1878 substr($w,0,1) =~ tr/a-z/A-Z/, $capital = 0 if $capital;
1879 if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") {
1882 } elsif ($wtype eq "sp") {
1885 } elsif ($wtype eq "da") {
1888 } elsif ($wmajt eq "c" || $wtype eq "wc") {
1889 $texiwdlen = 2 + $wlen;
1890 return "\@code\{$w\}";
1891 } elsif ($wtype eq "es") {
1892 $texiwdlen = 1 + $wlen;
1893 return "\@emph\{${w}";
1894 } elsif ($wtype eq "ee") {
1895 $texiwdlen = 1 + $wlen;
1897 } elsif ($wtype eq "eo") {
1898 $texiwdlen = 2 + $wlen;
1899 return "\@emph\{${w}\}";
1900 } elsif ($wtype eq "x ") {
1901 $texiwdlen = 0; # we don't need it in this case
1902 $capital = 1; # hack
1904 } elsif ($wtype eq "xe") {
1905 $texiwdlen = 0; # we don't need it in this case
1907 } elsif ($wmajt eq "i") {
1908 $texiwdlen = 0; # we don't need it in this case
1911 die "panic in word_texi: $wtype$w\n";
1917 my $item, $i, $mpname, $title, $wd;
1919 $item = $tstruct_next{$topitem};
1923 $mpname = $tstruct_pname{$item};
1924 foreach $i (@
$mpname) {
1925 $wd = &word_texi
($i);
1926 $title .= $wd unless $wd eq "\001";
1928 print "* ${item}:: $title\n";
1929 $item = $tstruct_mnext{$item};
1931 print "* Index::\n" if $topitem eq "Top";
1932 print "\@end menu\n";
1936 my $itag, $ientry, @a, $wd, $item, $len;
1937 my $subnums = "123456789ABCDEFGHIJKLMNOPQRSTU" .
1938 "VWXYZabcdefghijklmnopqrstuvwxyz";
1940 print "\@ifinfo\n\@node Index, , $FIXMElastnode, Top\n";
1941 print "\@unnumbered Index\n\n\@menu\n";
1943 foreach $itag (@itags) {
1944 $ientry = $idxmap{$itag};
1949 $wd = &word_texi
($i);
1950 $item .= $wd, $len += $texiwdlen unless $wd eq "\001";
1953 foreach $node (@nodes) {
1954 next if !$idxnodes{$node,$itag};
1955 printf "* %s%s (%s): %s.\n",
1956 $item, " " x
(40-$len), substr($subnums,$i++,1), $node;
1959 print "\@end menu\n\@end ifinfo\n";
1963 # This is called from the top level, so I won't bother using
1966 # Build the index-tag text forms.
1967 print "building index entries...";
1970 my $ientry = $idxmap{$_};
1972 foreach $i (@
$ientry) {
1973 $ww = &word_hlp
($i,0);
1974 $title .= $ww unless $ww eq "\001";
1979 # Write the HPJ project-description file.
1980 print "writing .hpj file...";
1981 open HPJ
,">nasmdoc.hpj";
1982 print HPJ
"[OPTIONS]\ncompress=true\n";
1983 print HPJ
"title=NASM: The Netwide Assembler\noldkeyphrase=no\n\n";
1984 print HPJ
"[FILES]\nnasmdoc.rtf\n\n";
1985 print HPJ
"[CONFIG]\n";
1986 print HPJ
'CreateButton("btn_up", "&Up",'.
1987 ' "JumpContents(`nasmdoc.hlp'."'".')")';
1988 print HPJ
"\nBrowseButtons()\n";
1992 print "\n writing .rtf file...";
1993 open TEXT
,">nasmdoc.rtf";
1997 print "{\\rtf1\\ansi{\\fonttbl\n";
1998 print "\\f0\\froman Times New Roman;\\f1\\fmodern Courier New;\n";
1999 print "\\f2\\fswiss Arial;\\f3\\ftech Wingdings}\\deff0\n";
2000 print "#{\\footnote Top}\n";
2001 print "\${\\footnote Contents}\n";
2002 print "+{\\footnote browse:00000}\n";
2003 print "!{\\footnote DisableButton(\"btn_up\")}\n";
2004 print "\\keepn\\f2\\b\\fs30\\sb0\n";
2005 print "NASM: The Netwide Assembler\n";
2006 print "\\par\\pard\\plain\\sb120\n";
2007 print "This file documents NASM, the Netwide Assembler: an assembler \n";
2008 print "targetting the Intel x86 series of processors, with portable source.\n";
2013 $newpar = "\\par\\sb120\n";
2014 for ($para = 0; $para <= $#pnames; $para++) {
2015 $pname = $pnames[$para];
2016 $pflags = $pflags[$para];
2017 $ptype = substr($pflags,0,4);
2020 $newpar = "\\par\\sb120\n";
2022 if ($ptype eq "chap") {
2023 # Chapter heading. Begin a new node.
2025 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
2026 $pflags =~ /chap (.*) :(.*)/;
2027 $node = "Chapter $1";
2028 $title = $footnotetitle = "Chapter $1: ";
2029 foreach $i (@
$pname) {
2030 $ww = &word_hlp
($i,1);
2031 $title .= $ww, $footnotetitle .= &word_hlp
($i,0) unless $ww eq "\001";
2034 printf "#{\\footnote %s}\n", &hlp_sectkw
($node);
2035 print "\${\\footnote $footnotetitle}\n";
2036 printf "+{\\footnote browse:%05d}\n", ++$browse;
2037 printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," .
2038 "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n",
2039 &hlp_sectkw
($tstruct_up{$node});
2040 print "EnableButton(\"btn_up\")}\n";
2041 &hlp_keywords
($node);
2042 print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n";
2044 $newpar = "\\par\\pard\\plain\\sb120\n";
2045 } elsif ($ptype eq "appn") {
2046 # Appendix heading. Begin a new node.
2048 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
2049 $pflags =~ /appn (.*) :(.*)/;
2050 $node = "Appendix $1";
2051 $title = $footnotetitle = "Appendix $1: ";
2052 foreach $i (@
$pname) {
2053 $ww = &word_hlp
($i,1);
2054 $title .= $ww, $footnotetitle .= &word_hlp
($i,0) unless $ww eq "\001";
2057 printf "#{\\footnote %s}\n", &hlp_sectkw
($node);
2058 print "\${\\footnote $footnotetitle}\n";
2059 printf "+{\\footnote browse:%05d}\n", ++$browse;
2060 printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," .
2061 "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n",
2062 &hlp_sectkw
($tstruct_up{$node});
2063 print "EnableButton(\"btn_up\")}\n";
2064 &hlp_keywords
($node);
2065 print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n";
2067 $newpar = "\\par\\pard\\plain\\sb120\n";
2068 } elsif ($ptype eq "head" || $ptype eq "subh") {
2069 # Heading or subheading. Begin a new node.
2071 if $tstruct_level{$tstruct_next{$node}} > $tstruct_level{$node};
2072 $pflags =~ /.... (.*) :(.*)/;
2073 $node = "Section $1";
2074 $title = $footnotetitle = "$1. ";
2075 foreach $i (@
$pname) {
2076 $ww = &word_hlp
($i,1);
2077 $title .= $ww, $footnotetitle .= &word_hlp
($i,0) unless $ww eq "\001";
2080 printf "#{\\footnote %s}\n", &hlp_sectkw
($node);
2081 print "\${\\footnote $footnotetitle}\n";
2082 printf "+{\\footnote browse:%05d}\n", ++$browse;
2083 printf "!{\\footnote ChangeButtonBinding(\"btn_up\"," .
2084 "\"JumpId(\`nasmdoc.hlp',\`%s')\");\n",
2085 &hlp_sectkw
($tstruct_up{$node});
2086 print "EnableButton(\"btn_up\")}\n";
2087 &hlp_keywords
($node);
2088 print "\\keepn\\f2\\b\\fs30\\sb60\\sa60\n";
2090 $newpar = "\\par\\pard\\plain\\sb120\n";
2091 } elsif ($ptype eq "code") {
2093 print "\\keep\\f1\\sb120\n";
2094 foreach $i (@
$pname) {
2095 warn "code line longer than 68 chars: $i\n" if length $i > 68;
2099 print "$i\\par\\sb0\n";
2101 $newpar = "\\pard\\f0\\sb120\n";
2102 } elsif ($ptype eq "bull" || $ptype eq "norm") {
2103 # Ordinary paragraph, optionally bulleted. We wrap, FWIW.
2104 if ($ptype eq "bull") {
2105 print "\\tx360\\li360\\fi-360{\\f3\\'9F}\\tab\n";
2106 $newpar = "\\par\\pard\\sb120\n";
2108 $newpar = "\\par\\sb120\n";
2114 do { $w = &word_hlp
((shift @a),1); } while $w eq "\001"; # hack
2116 if ($w eq ' ' || $w eq '' || $w eq undef) {
2117 if (length ($line . $wd) > 75) {
2118 $line =~ s/\s*$//; # trim trailing spaces
2119 print "$line \n"; # and put one back
2121 $wd =~ s/^\s*//; # trim leading spaces
2127 } while ($w ne '' && $w ne undef);
2128 if ($line =~ /\S/) {
2129 $line =~ s/\s*$//; # trim trailing spaces
2142 my ($w, $docode) = @_;
2145 return undef if $w eq '' || $w eq undef;
2146 $wtype = substr($w,0,2);
2147 $wmajt = substr($wtype,0,1);
2152 $w =~ s/<.*>// if $wmajt eq "w"; # remove web links
2153 substr($w,0,length($w)-1) =~ s/-/\\\'AD/g if $wmajt ne "x"; #nonbreakhyphens
2154 if ($wmajt eq "n" || $wtype eq "e " || $wtype eq "w ") {
2156 } elsif ($wtype eq "sp") {
2158 } elsif ($wtype eq "da") {
2160 } elsif ($wmajt eq "c" || $wtype eq "wc") {
2161 $w =~ s/ /\\\'A0/g; # make spaces non-breaking
2162 return $docode ?
"{\\f1 ${w}}" : $w;
2163 } elsif ($wtype eq "es") {
2165 } elsif ($wtype eq "ee") {
2167 } elsif ($wtype eq "eo") {
2168 return "{\\i ${w}}";
2169 } elsif ($wtype eq "x ") {
2171 } elsif ($wtype eq "xe") {
2172 $w = &hlp_sectkw
($w);
2173 return "}{\\v ${w}}";
2174 } elsif ($wmajt eq "i") {
2177 die "panic in word_hlp: $wtype$w\n";
2183 my $item, $kword, $i, $mpname, $title;
2185 $item = $tstruct_next{$topitem};
2186 print "\\li360\\fi-360\n";
2189 $mpname = $tstruct_pname{$item};
2190 foreach $i (@
$mpname) {
2191 $ww = &word_hlp
($i, 0);
2192 $title .= $ww unless $ww eq "\001";
2194 $kword = &hlp_sectkw
($item);
2195 print "{\\uldb ${item}: $title}{\\v $kword}\\par\\sb0\n";
2196 $item = $tstruct_mnext{$item};
2198 print "\\pard\\sb120\n";
2203 $node =~ tr/A-Z/a-z/;
2204 $node =~ tr/- ./___/;
2210 my $pfx = "K{\\footnote ";
2212 foreach $i (0..$#itags) {
2213 (print $pfx,$hlp_index[$i]), $pfx = ";\n", $done++
2214 if $idxnodes{$node,$itags[$i]};
2216 print "}\n" if $done;
2219 # Make tree structures. $tstruct_* is top-level and global.
2221 my ($item, $level) = @_;
2224 $tstruct_pname{$item} = $pname;
2225 $tstruct_next{$tstruct_previtem} = $item;
2226 $tstruct_prev{$item} = $tstruct_previtem;
2227 $tstruct_level{$item} = $level;
2228 $tstruct_up{$item} = $tstruct_last[$level-1];
2229 $tstruct_mnext{$tstruct_last[$level]} = $item;
2230 $tstruct_last[$level] = $item;
2231 for ($i=$level+1; $i<$MAXLEVEL; $i++) { $tstruct_last[$i] = undef; }
2232 $tstruct_previtem = $item;
2236 # PostScript font metric data. Used for line breaking.
2239 250, 0, 0, 0, 0, 0, 0, 0,
2240 0, 0, 0, 0, 0, 0, 0, 0,
2241 0, 0, 0, 0, 0, 0, 0, 0,
2242 0, 0, 0, 0, 0, 0, 0, 0,
2243 250, 333, 408, 500, 500, 833, 778, 333,
2244 333, 333, 500, 564, 250, 333, 250, 278,
2245 500, 500, 500, 500, 500, 500, 500, 500,
2246 500, 500, 278, 278, 564, 564, 564, 444,
2247 921, 722, 667, 667, 722, 611, 556, 722,
2248 722, 333, 389, 722, 611, 889, 722, 722,
2249 556, 722, 667, 556, 611, 722, 722, 944,
2250 722, 722, 611, 333, 278, 333, 469, 500,
2251 333, 444, 500, 444, 500, 444, 333, 500,
2252 500, 278, 278, 500, 278, 778, 500, 500,
2253 500, 500, 333, 389, 278, 500, 500, 722,
2254 500, 500, 444, 480, 200, 480, 541, 0,
2255 0, 0, 0, 0, 0, 0, 0, 0,
2256 0, 0, 0, 0, 0, 0, 0, 0,
2257 0, 0, 0, 0, 0, 0, 0, 0,
2258 0, 0, 0, 0, 0, 0, 0, 0,
2259 0, 333, 500, 500, 167, 500, 500, 500,
2260 500, 180, 444, 500, 333, 333, 556, 556,
2261 0, 500, 500, 500, 250, 0, 453, 350,
2262 333, 444, 444, 500,1000,1000, 0, 444,
2263 0, 333, 333, 333, 333, 333, 333, 333,
2264 333, 0, 333, 333, 0, 333, 333, 333,
2265 1000, 0, 0, 0, 0, 0, 0, 0,
2266 0, 0, 0, 0, 0, 0, 0, 0,
2267 0, 889, 0, 276, 0, 0, 0, 0,
2268 611, 722, 889, 310, 0, 0, 0, 0,
2269 0, 667, 0, 0, 0, 278, 0, 0,
2270 278, 500, 722, 500, 0, 0, 0, 0
2273 250, 0, 0, 0, 0, 0, 0, 0,
2274 0, 0, 0, 0, 0, 0, 0, 0,
2275 0, 0, 0, 0, 0, 0, 0, 0,
2276 0, 0, 0, 0, 0, 0, 0, 0,
2277 250, 333, 420, 500, 500, 833, 778, 333,
2278 333, 333, 500, 675, 250, 333, 250, 278,
2279 500, 500, 500, 500, 500, 500, 500, 500,
2280 500, 500, 333, 333, 675, 675, 675, 500,
2281 920, 611, 611, 667, 722, 611, 611, 722,
2282 722, 333, 444, 667, 556, 833, 667, 722,
2283 611, 722, 611, 500, 556, 722, 611, 833,
2284 611, 556, 556, 389, 278, 389, 422, 500,
2285 333, 500, 500, 444, 500, 444, 278, 500,
2286 500, 278, 278, 444, 278, 722, 500, 500,
2287 500, 500, 389, 389, 278, 500, 444, 667,
2288 444, 444, 389, 400, 275, 400, 541, 0,
2289 0, 0, 0, 0, 0, 0, 0, 0,
2290 0, 0, 0, 0, 0, 0, 0, 0,
2291 0, 0, 0, 0, 0, 0, 0, 0,
2292 0, 0, 0, 0, 0, 0, 0, 0,
2293 0, 389, 500, 500, 167, 500, 500, 500,
2294 500, 214, 556, 500, 333, 333, 500, 500,
2295 0, 500, 500, 500, 250, 0, 523, 350,
2296 333, 556, 556, 500, 889,1000, 0, 500,
2297 0, 333, 333, 333, 333, 333, 333, 333,
2298 333, 0, 333, 333, 0, 333, 333, 333,
2299 889, 0, 0, 0, 0, 0, 0, 0,
2300 0, 0, 0, 0, 0, 0, 0, 0,
2301 0, 889, 0, 276, 0, 0, 0, 0,
2302 556, 722, 944, 310, 0, 0, 0, 0,
2303 0, 667, 0, 0, 0, 278, 0, 0,
2304 278, 500, 667, 500, 0, 0, 0, 0
2307 600, 0, 0, 0, 0, 0, 0, 0,
2308 0, 0, 0, 0, 0, 0, 0, 0,
2309 0, 0, 0, 0, 0, 0, 0, 0,
2310 0, 0, 0, 0, 0, 0, 0, 0,
2311 600, 600, 600, 600, 600, 600, 600, 600,
2312 600, 600, 600, 600, 600, 600, 600, 600,
2313 600, 600, 600, 600, 600, 600, 600, 600,
2314 600, 600, 600, 600, 600, 600, 600, 600,
2315 600, 600, 600, 600, 600, 600, 600, 600,
2316 600, 600, 600, 600, 600, 600, 600, 600,
2317 600, 600, 600, 600, 600, 600, 600, 600,
2318 600, 600, 600, 600, 600, 600, 600, 600,
2319 600, 600, 600, 600, 600, 600, 600, 600,
2320 600, 600, 600, 600, 600, 600, 600, 600,
2321 600, 600, 600, 600, 600, 600, 600, 600,
2322 600, 600, 600, 600, 600, 600, 600, 0,
2323 0, 0, 0, 0, 0, 0, 0, 0,
2324 0, 0, 0, 0, 0, 0, 0, 0,
2325 0, 0, 0, 0, 0, 0, 0, 0,
2326 0, 0, 0, 0, 0, 0, 0, 0,
2327 0, 600, 600, 600, 600, 600, 600, 600,
2328 600, 600, 600, 600, 600, 600, 600, 600,
2329 0, 600, 600, 600, 600, 0, 600, 600,
2330 600, 600, 600, 600, 600, 600, 0, 600,
2331 0, 600, 600, 600, 600, 600, 600, 600,
2332 600, 0, 600, 600, 0, 600, 600, 600,
2333 600, 0, 0, 0, 0, 0, 0, 0,
2334 0, 0, 0, 0, 0, 0, 0, 0,
2335 0, 600, 0, 600, 0, 0, 0, 0,
2336 600, 600, 600, 600, 0, 0, 0, 0,
2337 0, 600, 0, 0, 0, 600, 0, 0,
2338 600, 600, 600, 600, 0, 0, 0, 0
2343 # This produces documentation intermediate paragraph format; this is
2344 # basically the digested output of the front end. Intended for use
2345 # by future backends, instead of putting it all in the same script.
2348 open(PARAS
, "> nasmdoc.dip");
2349 foreach $k (keys(%metadata)) {
2350 print PARAS
'meta :', $k, "\n";
2351 print PARAS
$metadata{$k},"\n";
2353 for ($para = 0; $para <= $#pnames; $para++) {
2354 print PARAS
$pflags[$para], "\n";
2355 print PARAS
join("\037", @
{$pnames[$para]}, "\n");
2357 foreach $k (@itags) {
2358 print PARAS
'indx :', $k, "\n";
2359 print PARAS
join("\037", @
{$idxmap{$k}}), "\n";