mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 04:10:18 +02:00
* snarf.h (SCM_SNARF_DOCS): change the "grammar" slightly.
* guile-snarf-docs.in, guile-snarf-docs-texi.in: rewrite & simplify. * eval.c: all hash signs are in column 0. * Makefile.am (guile_filter_doc_snarfage): build using c-tokenize.c, not filter-doc-snarfage.c. rearrange snarfing dependencies a bit. * c-tokenize.lex: new file.
This commit is contained in:
parent
fc7a9e81a6
commit
ac13d9d210
7 changed files with 212 additions and 49 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2001-06-25 Michael Livshin <mlivshin@bigfoot.com>
|
||||||
|
|
||||||
|
* snarf.h (SCM_SNARF_DOCS): change the "grammar" slightly.
|
||||||
|
|
||||||
|
* guile-snarf-docs.in, guile-snarf-docs-texi.in: rewrite &
|
||||||
|
simplify.
|
||||||
|
|
||||||
|
* eval.c: all hash signs are in column 0.
|
||||||
|
|
||||||
|
* Makefile.am (guile_filter_doc_snarfage): build using
|
||||||
|
c-tokenize.c, not filter-doc-snarfage.c.
|
||||||
|
rearrange snarfing dependencies a bit.
|
||||||
|
|
||||||
|
* c-tokenize.lex: new file.
|
||||||
|
|
||||||
2001-06-25 Marius Vollmer <mvo@zagadka.ping.de>
|
2001-06-25 Marius Vollmer <mvo@zagadka.ping.de>
|
||||||
|
|
||||||
* srcprop.h, srcprop.c (scm_srcprops_to_plist): Renamed from
|
* srcprop.h, srcprop.c (scm_srcprops_to_plist): Renamed from
|
||||||
|
|
|
@ -38,7 +38,7 @@ guile_SOURCES = guile.c
|
||||||
guile_LDADD = libguile.la ${THREAD_LIBS_LOCAL}
|
guile_LDADD = libguile.la ${THREAD_LIBS_LOCAL}
|
||||||
guile_LDFLAGS = @DLPREOPEN@
|
guile_LDFLAGS = @DLPREOPEN@
|
||||||
|
|
||||||
guile_filter_doc_snarfage_SOURCES = filter-doc-snarfage.c
|
guile_filter_doc_snarfage_SOURCES = c-tokenize.c
|
||||||
|
|
||||||
libguile_la_SOURCES = alist.c arbiters.c async.c backtrace.c boolean.c \
|
libguile_la_SOURCES = alist.c arbiters.c async.c backtrace.c boolean.c \
|
||||||
chars.c continuations.c debug.c deprecation.c dynl.c dynwind.c \
|
chars.c continuations.c debug.c deprecation.c dynl.c dynwind.c \
|
||||||
|
@ -185,8 +185,6 @@ libpath.h: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
@mv libpath.tmp libpath.h
|
@mv libpath.tmp libpath.h
|
||||||
|
|
||||||
|
|
||||||
# ./guile-snarf $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@
|
|
||||||
|
|
||||||
SUFFIXES = .x .doc
|
SUFFIXES = .x .doc
|
||||||
.c.x:
|
.c.x:
|
||||||
./guile-snarf $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
|
./guile-snarf $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $< > $@ \
|
||||||
|
@ -198,13 +196,13 @@ SUFFIXES = .x .doc
|
||||||
|
|
||||||
$(DOT_X_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf.in
|
$(DOT_X_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf.in
|
||||||
|
|
||||||
$(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf-docs.in guile_filter_doc_snarfage
|
$(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES): snarf.h guile-snarf-docs.in
|
||||||
|
|
||||||
error.x: cpp_err_symbols.c
|
error.x: cpp_err_symbols.c
|
||||||
posix.x: cpp_sig_symbols.c
|
posix.x: cpp_sig_symbols.c
|
||||||
load.x: libpath.h
|
load.x: libpath.h
|
||||||
|
|
||||||
guile.texi: $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) guile-snarf-docs-texi.in guile
|
guile.texi: $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) guile-snarf-docs-texi.in guile guile_filter_doc_snarfage
|
||||||
./guile-snarf-docs-texi $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) > $@ \
|
./guile-snarf-docs-texi $(DOT_DOC_FILES) $(EXTRA_DOT_DOC_FILES) > $@ \
|
||||||
|| { rm $@; false; }
|
|| { rm $@; false; }
|
||||||
|
|
||||||
|
|
180
libguile/c-tokenize.lex
Normal file
180
libguile/c-tokenize.lex
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
%option noyywrap
|
||||||
|
%pointer
|
||||||
|
|
||||||
|
EOL \n
|
||||||
|
SPACE [ \t\v\f]
|
||||||
|
WS [ \t\v\n\f]
|
||||||
|
DIGIT [0-9]
|
||||||
|
LETTER [a-zA-Z_]
|
||||||
|
OCTDIGIT [0-7]
|
||||||
|
HEXDIGIT [a-fA-F0-9]
|
||||||
|
EXPONENT [Ee][+-]?{DIGIT}+
|
||||||
|
FLOQUAL (f|F|l|L)
|
||||||
|
INTQUAL (l|L|ll|LL|lL|Ll|u|U)
|
||||||
|
|
||||||
|
%{
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int filter_snarfage = 0;
|
||||||
|
int print = 1;
|
||||||
|
|
||||||
|
enum t_state {
|
||||||
|
SKIP,
|
||||||
|
MULTILINE,
|
||||||
|
MULTILINE_COOKIE,
|
||||||
|
COOKIE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum t_state state = SKIP;
|
||||||
|
int cookie_was_last = 0;
|
||||||
|
|
||||||
|
#define OUT_RAW(type,text) if (print) printf ("(%s . \"%s\")\n", #type, text)
|
||||||
|
|
||||||
|
#define OUT_T(type) OUT_RAW (type, yytext)
|
||||||
|
#define OUT_S if (print) printf ("%s\n", yytext)
|
||||||
|
#define OUT(type) if (print) printf ("%s\n", #type)
|
||||||
|
|
||||||
|
#define IS_COOKIE cookie_was_last = 1
|
||||||
|
#define IS_NOT_COOKIE cookie_was_last = 0
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
\/\*(\n|[^*]|\*[^/])*\*\/ { OUT_T (comment); }
|
||||||
|
|
||||||
|
({SPACE}*(\\\n)*{SPACE}*)+ ;
|
||||||
|
|
||||||
|
({SPACE}*\n*{SPACE}*)+ { OUT(eol); }
|
||||||
|
|
||||||
|
# { OUT(hash); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
{LETTER}({LETTER}|{DIGIT})* { OUT_T (id); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
0[xX]{HEXDIGIT}+{INTQUAL}? { OUT_RAW (int_hex, yytext + 2); IS_NOT_COOKIE; }
|
||||||
|
0{OCTDIGIT}+{INTQUAL}? { OUT_RAW (int_oct, yytext + 1); IS_NOT_COOKIE; }
|
||||||
|
{DIGIT}+{INTQUAL}? { OUT_T (int_dec); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
L?\'(\\.|[^\\\'])+\' { OUT_T (char); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
{DIGIT}+{EXPONENT}{FLOQUAL}? { OUT_T (flo_dec); IS_NOT_COOKIE; }
|
||||||
|
{DIGIT}*"."{DIGIT}+({EXPONENT})?{FLOQUAL}? { OUT_T (flo_dec); IS_NOT_COOKIE; }
|
||||||
|
{DIGIT}+"."{DIGIT}*({EXPONENT})?{FLOQUAL}? { OUT_T (flo_dec); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
L?\"(\\.|[^\\\"])*\" { OUT_S; IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
"..." { OUT (ellipsis); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
">>=" { OUT (shift_right_assign); IS_NOT_COOKIE; }
|
||||||
|
"<<=" { OUT (shift_left_assign); IS_NOT_COOKIE; }
|
||||||
|
"+=" { OUT (add_assign); IS_NOT_COOKIE; }
|
||||||
|
"-=" { OUT (sub_assign); IS_NOT_COOKIE; }
|
||||||
|
"*=" { OUT (mul-assign); IS_NOT_COOKIE; }
|
||||||
|
"/=" { OUT (div_assign); IS_NOT_COOKIE; }
|
||||||
|
"%=" { OUT (mod_assign); IS_NOT_COOKIE; }
|
||||||
|
"&=" { OUT (logand_assign); IS_NOT_COOKIE; }
|
||||||
|
"^=" { OUT (logxor_assign); IS_NOT_COOKIE; }
|
||||||
|
"|=" { OUT (logior_assign); IS_NOT_COOKIE; }
|
||||||
|
">>" { OUT (right_shift); IS_NOT_COOKIE; }
|
||||||
|
"<<" { OUT (left_shift); IS_NOT_COOKIE; }
|
||||||
|
"++" { OUT (inc); IS_NOT_COOKIE; }
|
||||||
|
"--" { OUT (dec); IS_NOT_COOKIE; }
|
||||||
|
"->" { OUT (ptr); IS_NOT_COOKIE; }
|
||||||
|
"&&" { OUT (and); IS_NOT_COOKIE; }
|
||||||
|
"||" { OUT (or); IS_NOT_COOKIE; }
|
||||||
|
"<=" { OUT (le); IS_NOT_COOKIE; }
|
||||||
|
">=" { OUT (ge); IS_NOT_COOKIE; }
|
||||||
|
"==" { OUT (eq); IS_NOT_COOKIE; }
|
||||||
|
"!=" { OUT (ne); IS_NOT_COOKIE; }
|
||||||
|
";" { OUT (semicolon); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
("{"|"<%") {
|
||||||
|
OUT (brace_open);
|
||||||
|
if (filter_snarfage && cookie_was_last && state == COOKIE)
|
||||||
|
state = MULTILINE;
|
||||||
|
IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
("}"|"%>") {
|
||||||
|
OUT (brace_close);
|
||||||
|
if (filter_snarfage && cookie_was_last && state == MULTILINE_COOKIE) {
|
||||||
|
state = SKIP;
|
||||||
|
print = 0;
|
||||||
|
}
|
||||||
|
IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
"," { OUT (comma); IS_NOT_COOKIE; }
|
||||||
|
":" { OUT (colon); IS_NOT_COOKIE; }
|
||||||
|
"=" { OUT (assign); IS_NOT_COOKIE; }
|
||||||
|
"(" { OUT (paren_open); IS_NOT_COOKIE; }
|
||||||
|
")" { OUT (paren_close); IS_NOT_COOKIE; }
|
||||||
|
("["|"<:") { OUT (bracket_open); IS_NOT_COOKIE; }
|
||||||
|
("]"|":>") { OUT (bracket_close); IS_NOT_COOKIE; }
|
||||||
|
"." { OUT (dot); IS_NOT_COOKIE; }
|
||||||
|
"&" { OUT (amp); IS_NOT_COOKIE; }
|
||||||
|
"!" { OUT (bang); IS_NOT_COOKIE; }
|
||||||
|
"~" { OUT (tilde); IS_NOT_COOKIE; }
|
||||||
|
"-" { OUT (minus); IS_NOT_COOKIE; }
|
||||||
|
"+" { OUT (plus); IS_NOT_COOKIE; }
|
||||||
|
"*" { OUT (star); IS_NOT_COOKIE; }
|
||||||
|
"/" { OUT (slash); IS_NOT_COOKIE; }
|
||||||
|
"%" { OUT (percent); IS_NOT_COOKIE; }
|
||||||
|
"<" { OUT (lt); IS_NOT_COOKIE; }
|
||||||
|
">" { OUT (gt); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
\^{WS}*\^ {
|
||||||
|
if (filter_snarfage)
|
||||||
|
switch (state) {
|
||||||
|
case SKIP:
|
||||||
|
state = COOKIE;
|
||||||
|
print = 1;
|
||||||
|
OUT (snarf_cookie);
|
||||||
|
break;
|
||||||
|
case MULTILINE:
|
||||||
|
case MULTILINE_COOKIE:
|
||||||
|
state = MULTILINE_COOKIE;
|
||||||
|
OUT (snarf_cookie);
|
||||||
|
break;
|
||||||
|
case COOKIE:
|
||||||
|
state = SKIP;
|
||||||
|
OUT (snarf_cookie);
|
||||||
|
print = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* whoops */
|
||||||
|
abort ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
OUT (snarf_cookie);
|
||||||
|
|
||||||
|
IS_COOKIE; }
|
||||||
|
|
||||||
|
"^" { OUT (caret); IS_NOT_COOKIE; }
|
||||||
|
"|" { OUT (pipe); IS_NOT_COOKIE; }
|
||||||
|
"?" { OUT (question); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
. { fprintf (stderr, "*%s", yytext); fflush (stderr); IS_NOT_COOKIE; }
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
if (argc > 1 && !strcmp (argv[1], "--filter-snarfage")) {
|
||||||
|
filter_snarfage = 1;
|
||||||
|
print = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
yylex ();
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
c-file-style: "gnu"
|
||||||
|
End:
|
||||||
|
*/
|
|
@ -68,7 +68,7 @@
|
||||||
# include <alloca.h>
|
# include <alloca.h>
|
||||||
# else
|
# else
|
||||||
# ifdef _AIX
|
# ifdef _AIX
|
||||||
#pragma alloca
|
# pragma alloca
|
||||||
# else
|
# else
|
||||||
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
||||||
char *alloca ();
|
char *alloca ();
|
||||||
|
|
|
@ -24,37 +24,14 @@ bindir=`dirname $0`
|
||||||
bindir=`(cd $bindir; pwd)`
|
bindir=`(cd $bindir; pwd)`
|
||||||
srcdir=`(cd $srcdir; pwd)`
|
srcdir=`(cd $srcdir; pwd)`
|
||||||
|
|
||||||
temp0="/tmp/snarf.0.$$"
|
|
||||||
temp1="/tmp/snarf.1.$$"
|
|
||||||
trap "rm -f $temp0 $temp1" 0 1 2 15
|
|
||||||
|
|
||||||
# cat all the small files together:
|
|
||||||
cat "$@" > ${temp1}
|
|
||||||
|
|
||||||
## massage the arglists
|
|
||||||
|
|
||||||
# lose the SCM types and commas, and texi-quote @'s in names and args
|
|
||||||
< ${temp1} sed -e '/^arglist/s/[ ]*SCM[ ]*//g' \
|
|
||||||
-e '/^arglist/s/,/ /g' \
|
|
||||||
-e '/^arglist/s/([ ]*void[ ]*)/()/g' \
|
|
||||||
-e '/^fname/s/@/@@/g' \
|
|
||||||
-e '/^arglist/s/@/@@/g' \
|
|
||||||
> ${temp0}
|
|
||||||
|
|
||||||
# nothing to do with the docstrings
|
|
||||||
< ${temp0} sed -e 's/^string //' > ${temp1}
|
|
||||||
|
|
||||||
# we're too lame to check argpos assertions other then for straight names, so...
|
|
||||||
< ${temp1} sed -e 's/^argpos.*[(\[].*//' > ${temp0}
|
|
||||||
|
|
||||||
echo "@paragraphindent 0"
|
echo "@paragraphindent 0"
|
||||||
|
|
||||||
# now run the script that will generate texinfo
|
# run the script that will generate texinfo
|
||||||
main='(module-ref (resolve-module '\''(scripts snarf-check-and-output-texi)) '\''main)'
|
main='(module-ref (resolve-module '\''(scripts snarf-check-and-output-texi)) '\''main)'
|
||||||
apply_main="(apply $main (cdr (command-line)))"
|
apply_main="(apply $main (cdr (command-line)))"
|
||||||
|
|
||||||
if [ `basename ${bindir}` = libguile ]; then
|
if [ `basename ${bindir}` = libguile ]; then
|
||||||
GUILE_LOAD_PATH=${srcdir}/.. ${bindir}/guile -c "${apply_main}" < ${temp0}
|
GUILE_LOAD_PATH=${srcdir}/..; export GUILE_LOAD_PATH
|
||||||
else
|
|
||||||
${bindir}/guile -c "${apply_main}" < ${temp0}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat "$@" | ${bindir}/guile_filter_doc_snarfage --filter-snarfage | ${bindir}/guile -c "${apply_main}"
|
||||||
|
|
|
@ -20,13 +20,7 @@
|
||||||
|
|
||||||
bindir=`dirname $0`
|
bindir=`dirname $0`
|
||||||
|
|
||||||
temp="/tmp/snarf.$$"
|
|
||||||
trap "rm -f $temp" 0 1 2 15
|
|
||||||
|
|
||||||
## Let the user override the preprocessor autoconf found.
|
## Let the user override the preprocessor autoconf found.
|
||||||
test -n "${CPP+set}" || CPP="@CPP@"
|
test -n "${CPP+set}" || CPP="@CPP@"
|
||||||
|
|
||||||
## We must use a temporary file here, instead of a pipe, because we
|
${CPP} -DSCM_MAGIC_SNARF_DOCS "$@"
|
||||||
## need to know if CPP exits with a non-zero status.
|
|
||||||
${CPP} -DSCM_MAGIC_SNARF_DOCS "$@" > ${temp} || exit $?
|
|
||||||
< ${temp} ${bindir}/guile_filter_doc_snarfage
|
|
||||||
|
|
|
@ -85,14 +85,13 @@
|
||||||
# define SCM_SNARF_HERE(X)
|
# define SCM_SNARF_HERE(X)
|
||||||
# define SCM_SNARF_INIT(X)
|
# define SCM_SNARF_INIT(X)
|
||||||
# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) \
|
# define SCM_SNARF_DOCS(TYPE, FNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) \
|
||||||
^^{ \
|
^^ { \
|
||||||
^^%fname . FNAME \
|
fname FNAME ^^ \
|
||||||
^^%type . TYPE \
|
type TYPE ^^ \
|
||||||
^^%location __FILE__ . __LINE__ \
|
location __FILE__ __LINE__ ^^ \
|
||||||
^^%arglist . ARGLIST \
|
arglist ARGLIST ^^ \
|
||||||
^^%argsig REQ OPT VAR \
|
argsig REQ OPT VAR ^^ \
|
||||||
^^(DOCSTRING) \
|
DOCSTRING ^^ }
|
||||||
^^}
|
|
||||||
# else
|
# else
|
||||||
# define SCM_SNARF_HERE(X) X
|
# define SCM_SNARF_HERE(X) X
|
||||||
# define SCM_SNARF_INIT(X)
|
# define SCM_SNARF_INIT(X)
|
||||||
|
@ -219,7 +218,7 @@ SCM_SNARF_INIT(c_name = scm_permanent_object (scm_sysintern (scheme_name, init_v
|
||||||
|
|
||||||
#ifdef SCM_MAGIC_SNARF_DOCS
|
#ifdef SCM_MAGIC_SNARF_DOCS
|
||||||
#undef SCM_ASSERT
|
#undef SCM_ASSERT
|
||||||
#define SCM_ASSERT(_cond, _arg, _pos, _subr) ^^[ argpos _arg _pos __LINE__ ]
|
#define SCM_ASSERT(_cond, _arg, _pos, _subr) ^^ argpos _arg _pos __LINE__ ^^
|
||||||
#endif /* SCM_MAGIC_SNARF_DOCS */
|
#endif /* SCM_MAGIC_SNARF_DOCS */
|
||||||
|
|
||||||
#endif /* LIBGUILE_SNARF_H */
|
#endif /* LIBGUILE_SNARF_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue