Initial revision
This commit is contained in:
parent
3a26c0cd00
commit
90f3f3e2b0
13 changed files with 275 additions and 0 deletions
12
bfd/awkscan
Executable file
12
bfd/awkscan
Executable file
|
@ -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 }
|
8
bfd/awkscan-ip
Executable file
8
bfd/awkscan-ip
Executable file
|
@ -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" }
|
8
bfd/awkscan-p
Executable file
8
bfd/awkscan-p
Executable file
|
@ -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" }
|
8
bfd/blins-p
Executable file
8
bfd/blins-p
Executable file
|
@ -0,0 +1,8 @@
|
|||
# sed script for BFD header files
|
||||
# Merge adjacent blank lines. Loop til no change.
|
||||
:blin
|
||||
/^$/,/^ *[^ ]*.*$/{
|
||||
/^$/N
|
||||
s/^ *\n *$//
|
||||
}
|
||||
t blin
|
14
bfd/exfilter
Executable file
14
bfd/exfilter
Executable file
|
@ -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
|
||||
#
|
4
bfd/exmerge
Executable file
4
bfd/exmerge
Executable file
|
@ -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
|
5
bfd/mergecom-p
Executable file
5
bfd/mergecom-p
Executable file
|
@ -0,0 +1,5 @@
|
|||
# SED script for preprocessing embedded headers from C source comments
|
||||
# Locate and coalesce adjacent comments
|
||||
/\*\/$/N
|
||||
s/\*\/\n\/\*/\
|
||||
/
|
8
bfd/movecom-p
Executable file
8
bfd/movecom-p
Executable file
|
@ -0,0 +1,8 @@
|
|||
# sed script for BFD header files:
|
||||
# Transpose <blank line> <end comment>
|
||||
/^$/,/^ *[^ ]*.*$/{
|
||||
/^$/N
|
||||
/^ *\n\*\/$/c\
|
||||
*\/\
|
||||
|
||||
}
|
23
bfd/scanit
Executable file
23
bfd/scanit
Executable file
|
@ -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
|
||||
|
25
bfd/scanph
Executable file
25
bfd/scanph
Executable file
|
@ -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
|
85
bfd/sedscript
Executable file
85
bfd/sedscript
Executable file
|
@ -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\
|
||||
/
|
||||
}
|
63
bfd/sedscript-p
Executable file
63
bfd/sedscript-p
Executable file
|
@ -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/;$/;\
|
||||
\/*\
|
||||
/
|
||||
}
|
12
bfd/startcom-p
Executable file
12
bfd/startcom-p
Executable file
|
@ -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/
|
||||
}
|
Loading…
Reference in a new issue