• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Demonstration of groff .psbb request handling code, for EPS and PDF input files


Commit MetaInfo

Revisione25e11c6770a3d7a2e98cbcfce66dbffd7d8b5a0 (tree)
Zeit2017-10-17 06:06:35
AutorKeith Marshall <keith@user...>
CommiterKeith Marshall

Log Message

Add lexer state mapping for debugging trace logs.

* GNUmakefile (all): New default goal; it amalgamates...
(state.map): ...this new sed filter file target, along with...
(psbb): ...this original target, as default primary build goals.
(psbblex.map, psbblex.map.ls, psbblex.map.lx, psbblex.state.map)
(psbblex.map.l): New intermediate goals; in conjunction with...
(STATE_MAP_SCRIPT): ...this new macro, they are required to
facilitate the building of the final state.map target.
(vpath) [%.in, %.map]: Add $srcdir references.

* psbblex.map.in: New template file, for psbblex.map.l

Ändern Zusammenfassung

Diff

--- a/GNUmakefile
+++ b/GNUmakefile
@@ -21,7 +21,7 @@
2121 # You should have received a copy of the GNU General Public License
2222 # along with this program. If not, see <http://www.gnu.org/licenses/>.
2323 #
24-psbb:
24+all: psbb state.map
2525
2626 srcdir = .
2727 vpath %.l ${srcdir}
@@ -68,6 +68,37 @@ psbblex.o: psbblex.c psbb.tab.h psbb.h
6868 t-psbb.o psbblex.o psbb.tab.o error.o errarg.o: error.h errarg.h
6969 t-psbb.o: psbb.h
7070
71+
72+# Rules to derive, from psbblex.l source, a sed filter for mapping
73+# of lexer state values, as they appear in debugging trace log files,
74+# back to their original state names.
75+#
76+vpath %.in ${srcdir}
77+vpath %.map ${srcdir}
78+
79+state.map: psbblex.l psbblex.map.in
80+ $(MAKE) --no-print-directory psbblex.$@
81+ mv psbblex.$@ $@
82+
83+%.state.map: %.l %.map.in
84+ $(MAKE) --no-print-directory $*.map
85+ echo "#! $(shell which sed) -f" > $@
86+ ./$*.map >> $@ && chmod 755 $@
87+ $(RM) $*.map
88+
89+%.map.lx: %.l
90+ sed -n -e '/^%x/{s/ */\n%x /g' -e 's/^%x\n//p' -e '}' $^ > $@
91+
92+%.map.ls: %.map.lx
93+ sed -e 's/ *%x */ SHOW(/' -e 's/$$/);/' $< > $@
94+
95+%.map.l: %.map.in %.map.ls
96+ sed $(STATE_MAP_SCRIPT) $< > $@
97+
98+STATE_MAP_SCRIPT = -e '/@LEXER_STATE_MAP@/{r $@x' -e d -e '}' \
99+ -e '/@SED_FILTER_RULES@/{r $@s' -e d -e '}'
100+
101+
71102 # Clean up rules
72103 #
73104 clean:; $(RM) *.o psbb
--- /dev/null
+++ b/psbblex.map.in
@@ -0,0 +1,55 @@
1+/* psbblex.map.in
2+ *
3+ * A simplified lexical analyser template, derived from psbblex.l, whence
4+ * a state mapping filter for debugging trace logs may be created.
5+ *
6+ * Written by Keith Marshall <keith@users.osdn.me>
7+ * Copyright (C) 2017, Free Software Foundation, Inc.
8+ *
9+ * This file is part of groff.
10+ *
11+ * groff is free software; you can redistribute it and/or modify it under
12+ * the terms of the GNU General Public License as published by the Free
13+ * Software Foundation, either version 3 of the License, or
14+ * (at your option) any later version.
15+ *
16+ * groff is distributed in the hope that it will be useful, but WITHOUT ANY
17+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
18+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19+ * for more details.
20+ *
21+ * You should have received a copy of the GNU General Public License
22+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
23+ *
24+ *
25+ * The following lexer state mapping template is substituted at build time
26+ * by the complete set of state declarations, in order, which is abstracted
27+ * from psbblex.l itself.
28+ *
29+ */
30+@LEXER_STATE_MAP@
31+%option noyywrap
32+
33+%%
34+ /* A minimal pattern rule set, for the INITIAL state only; this
35+ * makes yylex() a no-op, and is never actually used.
36+ */
37+.|\n |
38+<<EOF>> { return 0; }
39+%%
40+#include <stdio.h>
41+
42+/* Macro, representing a sed filter rule to map a single lexer state.
43+ */
44+#define SHOW(STATE) printf( "s/^%d:/& %s:/\n", STATE, #STATE )
45+
46+int main()
47+{ /* The preceding macro is substituted here, at build time, once for
48+ * each lexer state, to generate the complete set state mapping sed
49+ * filter rules.
50+ */
51+ @SED_FILTER_RULES@
52+ return 0;
53+}
54+
55+/* vim: set ft=lex cin fo=croqj: */