aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Chamberlain <steve@cygnus>1991-08-17 00:16:57 +0000
committerSteve Chamberlain <steve@cygnus>1991-08-17 00:16:57 +0000
commit90f3f3e2b046a492b08d8802fd6e2055508b795e (patch)
tree2cee2df785574d5200035c64b9a81a09036ec9e4
parent3a26c0cd00b712a85b63ad962ff72d125154b1bc (diff)
downloadbinutils-90f3f3e2b046a492b08d8802fd6e2055508b795e.zip
binutils-90f3f3e2b046a492b08d8802fd6e2055508b795e.tar.gz
binutils-90f3f3e2b046a492b08d8802fd6e2055508b795e.tar.bz2
Initial revision
-rwxr-xr-xbfd/awkscan12
-rwxr-xr-xbfd/awkscan-ip8
-rwxr-xr-xbfd/awkscan-p8
-rwxr-xr-xbfd/blins-p8
-rwxr-xr-xbfd/exfilter14
-rwxr-xr-xbfd/exmerge4
-rwxr-xr-xbfd/mergecom-p5
-rwxr-xr-xbfd/movecom-p8
-rwxr-xr-xbfd/scanit23
-rwxr-xr-xbfd/scanph25
-rwxr-xr-xbfd/sedscript85
-rwxr-xr-xbfd/sedscript-p63
-rwxr-xr-xbfd/startcom-p12
13 files changed, 275 insertions, 0 deletions
diff --git a/bfd/awkscan b/bfd/awkscan
new file mode 100755
index 0000000..69b0cea
--- /dev/null
+++ b/bfd/awkscan
@@ -0,0 +1,12 @@
+# NOTE: BEGIN pattern gives errors if other than 1st line;
+# END ditto if other than last.
+BEGIN { print "@c ------------------------------START TEXT FROM " FILENAME }
+#
+# Keep /*doc* blocks (terminated by either */ or *-*/)
+/^\/\*doc\*/,/^\*\/|^\*-\*\//
+#
+# Also keep two kinds of /*proto blocks
+/^\/\*proto\*/,/^\*\/|^\*-\*\//
+/^\/\*proto-internal\*/,/^\*\/|^\*-\*\//
+#
+END { print "@c ------------------------------END TEXT FROM " FILENAME }
diff --git a/bfd/awkscan-ip b/bfd/awkscan-ip
new file mode 100755
index 0000000..01e3c05
--- /dev/null
+++ b/bfd/awkscan-ip
@@ -0,0 +1,8 @@
+# NOTE: BEGIN pattern gives errors if other than 1st line;
+# END ditto if other than last.
+BEGIN { print "/* ------------------------------START FROM " FILENAME "*/" }
+#
+# keep /*proto-internal blocks
+/^\/\*proto-internal\*/,/^\*\/|^\*-\*\//
+#
+END { print "/* --------------------------------END FROM " FILENAME "*/\n" }
diff --git a/bfd/awkscan-p b/bfd/awkscan-p
new file mode 100755
index 0000000..f7240dd
--- /dev/null
+++ b/bfd/awkscan-p
@@ -0,0 +1,8 @@
+# NOTE: BEGIN pattern gives errors if other than 1st line;
+# END ditto if other than last.
+BEGIN { print "/* ------------------------------START FROM " FILENAME "*/" }
+#
+# keep /*proto blocks
+/^\/\*proto\*/,/^\*\/|^\*-\*\//
+#
+END { print "/* --------------------------------END FROM " FILENAME "*/\n" }
diff --git a/bfd/blins-p b/bfd/blins-p
new file mode 100755
index 0000000..858dcd7
--- /dev/null
+++ b/bfd/blins-p
@@ -0,0 +1,8 @@
+# sed script for BFD header files
+# Merge adjacent blank lines. Loop til no change.
+:blin
+/^$/,/^ *[^ ]*.*$/{
+/^$/N
+s/^ *\n *$//
+}
+t blin
diff --git a/bfd/exfilter b/bfd/exfilter
new file mode 100755
index 0000000..7551607
--- /dev/null
+++ b/bfd/exfilter
@@ -0,0 +1,14 @@
+# SED script for preprocessing embedded doc from source (S. Chamberlain markup)
+# Final pass; cleanup work is done here.
+#
+# Within examples, make '{' and '}' printable:
+/^@lisp$/,/^@end lisp$/s/{/@{/
+/^@lisp$/,/^@end lisp$/s/}/@}/
+/^@example$/,/^@end example$/s/{/@{/
+/^@example$/,/^@end example$/s/}/@}/
+#
+# Delete empty @findex and @subsubsection entries (resulting from *proto*
+# with no further text on same line, in middle pass)
+/^@findex $/d
+/^@subsubsection @code{}/d
+#
diff --git a/bfd/exmerge b/bfd/exmerge
new file mode 100755
index 0000000..dafa424
--- /dev/null
+++ b/bfd/exmerge
@@ -0,0 +1,4 @@
+# SED script for preprocessing embedded doc from source (S. Chamberlain markup)
+# Locate and coalesce adjacent @example blocks
+/^@end example/N
+/^@end example\n@example$/d
diff --git a/bfd/mergecom-p b/bfd/mergecom-p
new file mode 100755
index 0000000..456478b
--- /dev/null
+++ b/bfd/mergecom-p
@@ -0,0 +1,5 @@
+# SED script for preprocessing embedded headers from C source comments
+# Locate and coalesce adjacent comments
+/\*\/$/N
+s/\*\/\n\/\*/\
+/
diff --git a/bfd/movecom-p b/bfd/movecom-p
new file mode 100755
index 0000000..7ed04c7
--- /dev/null
+++ b/bfd/movecom-p
@@ -0,0 +1,8 @@
+# sed script for BFD header files:
+# Transpose <blank line> <end comment>
+/^$/,/^ *[^ ]*.*$/{
+/^$/N
+/^ *\n\*\/$/c\
+*\/\
+
+}
diff --git a/bfd/scanit b/bfd/scanit
new file mode 100755
index 0000000..31c8232
--- /dev/null
+++ b/bfd/scanit
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Script to coordinate parsing of S. Chamberlain source-embedded
+# documentation markup language.
+
+# Four passes:
+# 1) awk discards lines not intended for docn, and marks blocks of
+# text with comments identifying source file;
+# 2) first sed pass interprets Chamberlain markup;
+# 3) second sed pass does cleanup that involves merging lines
+# 4) third sed pass does remaining cleans up---making {}
+# printable within examples, and eliminating empty index entries and
+# headings.
+#Third and second sed passes are separate because order of execution is hard
+#to control otherwise, making one or another of the things involving @example
+#inoperative.
+
+base=`echo $1 | cut -d '.' -f 1`
+
+awk -f awkscan $1 | \
+sed -f sedscript | \
+sed -f exmerge | \
+sed -f exfilter >$base.texi
+
diff --git a/bfd/scanph b/bfd/scanph
new file mode 100755
index 0000000..46912c3
--- /dev/null
+++ b/bfd/scanph
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Script to coordinate parsing of S. Chamberlain source-embedded
+# header-file markup language.
+
+# '-i' option means use *proto-internal* segments, else just *proto*
+SFX=p
+if [ $1 = "-i" ]; then
+ SFX=ip
+ shift
+fi
+
+base=`echo $1 | cut -d '.' -f 1`
+
+# passes:
+# 1) awk discards lines not intended for header, and marks blocks of
+# text with comments identifying source file;
+# 2) first sed pass interprets Chamberlain markup;
+# 3) further sed passes clean up---merging adjacent comments etc.
+
+awk -f awkscan-$SFX $1 |\
+sed -f sedscript-p |\
+sed -f mergecom-p |\
+sed -f startcom-p |\
+sed -f blins-p |\
+sed -f movecom-p >$base.$SFX
diff --git a/bfd/sedscript b/bfd/sedscript
new file mode 100755
index 0000000..e8e225d
--- /dev/null
+++ b/bfd/sedscript
@@ -0,0 +1,85 @@
+# SED script for preprocessing embedded doc from source (S. Chamberlain markup)
+# middle pass; most of the work is done here.
+#
+# First, get rid of /*doc* markers; they've done their job in the first pass.
+/^\/\*doc\*/d
+#
+# /*proto* markers may be optionally followed by a *i-style subsubsec, findex
+# entry. This will generate empty @findex and @subsubsection entries if
+# the *proto* is on a line by itself; third pass removes them.
+/^\/\*proto\*/s/^\/\*proto\* *\(.*\)$/@findex \1\
+@subsubsection @code{\1}/
+#
+# /*proto-internal* is just like /*proto* from doc point of view.
+/^\/\*proto-internal\*/s/^\/\*proto-internal\* *\(.*\)$/@findex \1\
+@subsubsection @code{\1}/
+#
+# *i at beginning of line: rest of line is both a subsubsection heading
+# and an entry in function index.
+/^\*i/s/^\*i *\(.*\)$/@findex \1\
+@subsubsection @code{\1}/
+#
+# Two alternative docn block ends, '*/' and '*-*/' on lines by themselves;
+# replace by blank lines (for texinfo source readability).
+/^\*\/$/c\
+
+/^\*-\*\/$/c\
+
+# {* and *} are standins for comment markers (originally embedded in .c
+# comments)---turn into real comment markers:
+s/{\*/\/\*/
+s/\*}/\*\//
+#
+# '*+++' and '*---' span a block of text that includes both example lines
+# (marked by leading '$') and explanatory text (to be italicized).
+# Italicize lines lacking '$':
+/\*\+\+\+/,/\*---/s/^\([^$].*\)$/@i{\1}/
+#
+# We don't need *+++ and *--- markers any more; kill them (trailing marker
+# becomes blank line for readability)
+/\*\+\+\+/d
+/\*---/c\
+
+# Any line beginning with '$' is made an example line; third pass later
+# coalesces adjacent example blocks. *DO NOT* introduce extra space after
+# @end example, so we can spot adjacent ones in third pass.
+/^\$/i\
+@example
+/^\$/a\
+@end example
+#
+# In any example line, turn '{' and '}' into '@{' and '@}'
+###/^\$/s/{/@{/g
+###/^\$/s/}/@}/g
+#
+# Now delete the '$' markers themselves:
+/^\$/s/\$//
+#
+# *+ and *- delimit large examples to be enclosed in cartouches.
+/^\*\+$/c\
+@lisp\
+@cartouche
+/^\*-$/c\
+@end cartouche\
+@end lisp\
+
+# '*;' introduces an example which may have a single line or multiple lines;
+# it extends until the next semicolon (which is also printed).
+# One-line case: (do this first; else second line address for multi-line case
+# will include random text til we happen to end a line in a doc comment with
+# a semicolon)
+/^\*;.*;$/{
+s/^\*;/@example\
+/
+s/;$/;\
+@end example\
+/
+}
+# Multi-line case:
+/^\*;/,/.*;$/{
+s/^\*;/@example\
+/
+s/;$/;\
+@end example\
+/
+}
diff --git a/bfd/sedscript-p b/bfd/sedscript-p
new file mode 100755
index 0000000..1f24900
--- /dev/null
+++ b/bfd/sedscript-p
@@ -0,0 +1,63 @@
+# SED script for preprocessing embedded headers from source
+# (S. Chamberlain markup)
+# middle pass; most of the work is done here.
+#
+# First, get rid of /*proto* markers; they've done their job in the first pass.
+# (They remain comment-introducers)
+/^\/\*proto\*/s/^\/\*proto\*/\/*/
+/^\/\*proto-internal\*/s/^\/\*proto-internal\*/\/*/
+#
+# *-*/ is an alternative (older) comment-block end. Remap for uniformity:
+s/^\*-\*\//\*\//
+#
+# {* and *} are standins for comment markers (originally embedded in .c
+# comments)---turn into real comment markers:
+s/{\*/\/\*/
+s/\*}/\*\//
+#
+# '*+++' and '*---' span a block of text that includes both header lines
+# (marked by leading '$') and explanatory text (to be comments).
+# No need to start comment at "*+++", or end it at "*---", since we're
+# already in a *proto* comment block. Just delete.
+/\*\+\+\+/d
+/\*---/d
+#
+# Any line beginning with '$' is made a line of code in the header;
+# stuff in between is comments, so *precede* each '$' line with
+# END-comment, *follow* each '$' line with START-comment; third pass later
+# eliminates empty comment blocks.
+/^\$/i\
+*/
+/^\$/a\
+/*
+#
+# Now delete the '$' markers themselves:
+/^\$/s/\$//
+#
+# *+ and *- delimit larger blocks of code, treated the same as '$' lines
+/^\*\+$/c\
+*/
+/^\*-$/c\
+/*
+#
+# '*;' introduces code which may have a single line or multiple lines;
+# it extends until the next semicolon (which is also printed).
+#
+# One-line case: (do this first; else second line address for multi-line case
+# will include random text til we happen to end a line in a proto comment with
+# a semicolon)
+/^\*;.*;$/{
+s/^\*;/*\/\
+/
+s/;$/;\
+\/*\
+/
+}
+# Multi-line case:
+/^\*;/,/.*;$/{
+s/^\*;/*\/\
+/
+s/;$/;\
+\/*\
+/
+}
diff --git a/bfd/startcom-p b/bfd/startcom-p
new file mode 100755
index 0000000..0748fad
--- /dev/null
+++ b/bfd/startcom-p
@@ -0,0 +1,12 @@
+# sed script for preprocessing BFD header files
+# <start comment> activity:
+/^\/\*$/{
+N
+# Delete empty comment blocks
+/^\/\*\n\*\/ *$/d
+# Transpose <start comment><blank line>
+s/^\/\*\n *$/\
+\/*/
+# merge <start comment> on line by itself with following line
+s/^\/\*\n\(.*\)/\/* \1/
+}