Skip to content

Commit 2428473

Browse files
authored
[spec] Check and fix cross-references (#1746)
1 parent beb8fb5 commit 2428473

File tree

5 files changed

+53
-30
lines changed

5 files changed

+53
-30
lines changed

document/core/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ publish-main: clean main bikeshed-keep deploy
8080
all: pdf html bikeshed
8181

8282
.PHONY: main
83-
main: pdf html
83+
main: macrosok pdf html
8484

8585
# Dirty hack to avoid rebuilding the Bikeshed version for every push.
8686
.PHONY: bikeshed-keep
@@ -97,6 +97,10 @@ GENERATED = appendix/index-instructions.rst
9797
%.rst: %.py
9898
(cd `dirname $@`; ./`basename $^`)
9999

100+
.PHONY: macrosok
101+
macrosok: $(GENERATED)
102+
sh util/check_macros.sh
103+
100104
.PHONY: pdf
101105
pdf: $(GENERATED) latexpdf
102106
mkdir -p $(BUILDDIR)/html/$(DOWNLOADDIR)

document/core/text/lexical.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ Any token that does not fall into any of the other categories is considered *res
7171

7272
.. index:: ! white space, character, ASCII
7373
single: text format; white space
74-
.. _text-format:
7574
.. _text-space:
75+
.. _text-format:
76+
.. _text-newline:
7677

7778
White Space
7879
~~~~~~~~~~~

document/core/text/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ As another abbreviation, element segments may also be specified inline with :ref
569569
single: data; segment
570570
.. _text-datastring:
571571
.. _text-data:
572-
.. _test-memuse:
572+
.. _text-memuse:
573573

574574
Data Segments
575575
~~~~~~~~~~~~~

document/core/util/check_macros.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
cd `dirname $0`/..
4+
5+
FILES=`ls */*.rst`
6+
ERRORS=0
7+
8+
for XREF in `grep xref util/macros.def`; do
9+
if echo $XREF | grep -q "[|]"; then
10+
MACRO=`echo $XREF | sed 's/^[^|]*[|]//g' | sed 's/[|].*$//g'`
11+
elif echo $XREF | grep -q xref; then
12+
FILE=`echo $XREF | sed 's/^.*xref{//g' | sed 's/}.*$//g'`.rst
13+
LABEL=`echo $XREF | sed 's/^[^}]*}{//g' | sed 's/}.*$//g'`
14+
TARGET=".. _$LABEL:"
15+
if ! [ -f $FILE ] || ! grep -q "$TARGET" $FILE; then
16+
ERRORS=1
17+
echo Undefined cross-reference $FILE:$LABEL in macro "|$MACRO|"
18+
if ! [ -f $FILE ]; then
19+
echo ...non-existent file $FILE
20+
fi
21+
if grep -q "$TARGET" $FILES; then
22+
echo ...defined in `grep -l "$TARGET" $FILES`
23+
fi
24+
fi
25+
fi
26+
done
27+
28+
if [ $ERRORS -eq 0 ]; then
29+
echo All cross-references okay.
30+
else
31+
exit 1;
32+
fi

document/core/util/macros.def

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@
177177

178178
.. |to| mathdef:: \xref{syntax/types}{syntax-functype}{\rightarrow}
179179

180-
.. |I8| mathdef:: \xref{exec/runtime}{syntax-storagetype}{\K{i8}}
181-
.. |I16| mathdef:: \xref{exec/runtime}{syntax-storagetype}{\K{i16}}
182180
.. |I32| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{i32}}
183181
.. |I64| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{i64}}
184182
.. |F32| mathdef:: \xref{syntax/types}{syntax-valtype}{\K{f32}}
@@ -227,8 +225,8 @@
227225

228226
.. |externtype| mathdef:: \xref{syntax/types}{syntax-externtype}{\X{externtype}}
229227

230-
.. |stacktype| mathdef:: \xref{syntax/types}{syntax-stacktype}{\X{stacktype}}
231-
.. |opdtype| mathdef:: \xref{syntax/types}{syntax-opdtype}{\X{opdtype}}
228+
.. |stacktype| mathdef:: \xref{valid/instructions}{syntax-stacktype}{\X{stacktype}}
229+
.. |opdtype| mathdef:: \xref{valid/instructions}{syntax-opdtype}{\X{opdtype}}
232230

233231

234232
.. Types, meta functions
@@ -523,9 +521,7 @@
523521
.. |vunop| mathdef:: \xref{syntax/instructions}{syntax-vunop}{\X{vunop}}
524522
.. |vbinop| mathdef:: \xref{syntax/instructions}{syntax-vbinop}{\X{vbinop}}
525523
.. |vrelop| mathdef:: \xref{syntax/instructions}{syntax-vrelop}{\X{vrelop}}
526-
.. |vternop| mathdef:: \xref{syntax/instructions}{syntax-vternop}{\X{vternop}}
527524
.. |vcvtop| mathdef:: \xref{syntax/instructions}{syntax-vcvtop}{\X{vcvtop}}
528-
.. |vextmul| mathdef:: \xref{syntax/instructions}{syntax-vextmul}{\X{vextmul}}
529525

530526
.. |laneidx| mathdef:: \xref{syntax/instructions}{syntax-laneidx}{\X{laneidx}}
531527
.. |vvunop| mathdef:: \xref{syntax/instructions}{syntax-vvunop}{\X{vvunop}}
@@ -797,19 +793,10 @@
797793
.. |Tlocalidx| mathdef:: \xref{text/modules}{text-localidx}{\T{localidx}}
798794
.. |Tlabelidx| mathdef:: \xref{text/modules}{text-labelidx}{\T{labelidx}}
799795

800-
.. |Ttypebind| mathdef:: \xref{text/modules}{text-typebind}{\T{typebind}}
801-
.. |Tfuncbind| mathdef:: \xref{text/modules}{text-funcbind}{\T{funcbind}}
802-
.. |Ttablebind| mathdef:: \xref{text/modules}{text-tablebind}{\T{tablebind}}
803-
.. |Tmembind| mathdef:: \xref{text/modules}{text-membind}{\T{membind}}
804-
.. |Tglobalbind| mathdef:: \xref{text/modules}{text-globalbind}{\T{globalbind}}
805-
.. |Tlocalbind| mathdef:: \xref{text/modules}{text-localbind}{\T{localbind}}
806-
.. |Tlabelbind| mathdef:: \xref{text/modules}{text-labelbind}{\T{labelbind}}
807-
808796

809797
.. Modules, non-terminals
810798

811799
.. |Tmodule| mathdef:: \xref{text/modules}{text-module}{\T{module}}
812-
.. |Tmodulebody| mathdef:: \xref{text/modules}{text-modulebody}{\T{modulebody}}
813800
.. |Tmodulefield| mathdef:: \xref{text/modules}{text-modulefield}{\T{modulefield}}
814801
.. |Ttype| mathdef:: \xref{text/modules}{text-typedef}{\T{type}}
815802
.. |Ttypeuse| mathdef:: \xref{text/modules}{text-typeuse}{\T{typeuse}}
@@ -825,7 +812,6 @@
825812
.. |Telemlist| mathdef:: \xref{text/modules}{text-elemlist}{\T{elemlist}}
826813
.. |Telemexpr| mathdef:: \xref{text/modules}{text-elemexpr}{\T{elemexpr}}
827814
.. |Ttableuse| mathdef:: \xref{text/modules}{text-tableuse}{\T{tableuse}}
828-
.. |Tcode| mathdef:: \xref{text/modules}{text-code}{\T{code}}
829815
.. |Tlocal| mathdef:: \xref{text/modules}{text-local}{\T{local}}
830816
.. |Tlocals| mathdef:: \xref{text/modules}{text-local}{\T{locals}}
831817
.. |Tdata| mathdef:: \xref{text/modules}{text-data}{\T{data}}
@@ -940,10 +926,10 @@
940926

941927
.. Notation
942928

943-
.. |stepto| mathdef:: \xref{exec/conventions}{formal-notation}{\hookrightarrow}
929+
.. |stepto| mathdef:: \xref{exec/conventions}{exec-notation}{\hookrightarrow}
944930
.. |extendsto| mathdef:: \xref{appendix/properties}{extend}{\preceq}
945-
.. |matchesexterntype| mathdef:: \xref{exec/modules}{match-externtype}{\leq}
946-
.. |matcheslimits| mathdef:: \xref{exec/modules}{match-limits}{\leq}
931+
.. |matchesexterntype| mathdef:: \xref{valid/types}{match-externtype}{\leq}
932+
.. |matcheslimits| mathdef:: \xref{valid/types}{match-limits}{\leq}
947933

948934

949935
.. Allocation
@@ -1081,7 +1067,7 @@
10811067
.. Values & Results, non-terminals
10821068

10831069
.. |num| mathdef:: \xref{exec/runtime}{syntax-num}{\X{num}}
1084-
.. |vecc| mathdef:: \xref{exec/runtime}{syntax-vec}{\X{vec}}
1070+
.. |vecc| mathdef:: \xref{exec/runtime}{syntax-vecc}{\X{vec}}
10851071
.. |reff| mathdef:: \xref{exec/runtime}{syntax-ref}{\X{ref}}
10861072
.. |val| mathdef:: \xref{exec/runtime}{syntax-val}{\X{val}}
10871073
.. |result| mathdef:: \xref{exec/runtime}{syntax-result}{\X{result}}
@@ -1144,10 +1130,10 @@
11441130
.. |imins| mathdef:: \xref{exec/numerics}{op-imin_s}{\F{imin\_s}}
11451131
.. |imaxu| mathdef:: \xref{exec/numerics}{op-imax_u}{\F{imax\_u}}
11461132
.. |imaxs| mathdef:: \xref{exec/numerics}{op-imax_s}{\F{imax\_s}}
1147-
.. |iaddsatu| mathdef:: \xref{exec/numerics}{op-iaddsat_u}{\F{iaddsat\_u}}
1148-
.. |iaddsats| mathdef:: \xref{exec/numerics}{op-iaddsat_s}{\F{iaddsat\_s}}
1149-
.. |isubsatu| mathdef:: \xref{exec/numerics}{op-isubsat_u}{\F{isubsat\_u}}
1150-
.. |isubsats| mathdef:: \xref{exec/numerics}{op-isubsat_s}{\F{isubsat\_s}}
1133+
.. |iaddsatu| mathdef:: \xref{exec/numerics}{op-iadd_sat_u}{\F{iadd\_sat\_u}}
1134+
.. |iaddsats| mathdef:: \xref{exec/numerics}{op-iadd_sat_s}{\F{iadd\_sat\_s}}
1135+
.. |isubsatu| mathdef:: \xref{exec/numerics}{op-isub_sat_u}{\F{isub\_sat\_u}}
1136+
.. |isubsats| mathdef:: \xref{exec/numerics}{op-isub_sat_s}{\F{isub\_sat\_s}}
11511137
.. |iavgru| mathdef:: \xref{exec/numerics}{op-iavgr_u}{\F{iavgr\_u}}
11521138
.. |iq15mulrsats| mathdef:: \xref{exec/numerics}{op-iq15mulrsat_s}{\F{iq15mulrsat\_s}}
11531139

@@ -1223,8 +1209,8 @@
12231209

12241210
.. |vdashexternval| mathdef:: \xref{exec/modules}{valid-externval}{\vdash}
12251211

1226-
.. |vdashlimitsmatch| mathdef:: \xref{exec/modules}{match-limits}{\vdash}
1227-
.. |vdashexterntypematch| mathdef:: \xref{exec/modules}{match-externtype}{\vdash}
1212+
.. |vdashlimitsmatch| mathdef:: \xref{valid/types}{match-limits}{\vdash}
1213+
.. |vdashexterntypematch| mathdef:: \xref{valid/types}{match-externtype}{\vdash}
12281214

12291215

12301216
.. Soundness
@@ -1234,7 +1220,7 @@
12341220

12351221
.. |vdashadmininstr| mathdef:: \xref{appendix/properties}{valid-instr-admin}{\vdash}
12361222

1237-
.. |vdashval| mathdef:: \xref{appendix/properties}{valid-val}{\vdash}
1223+
.. |vdashval| mathdef:: \xref{exec/modules}{valid-val}{\vdash}
12381224
.. |vdashresult| mathdef:: \xref{appendix/properties}{valid-result}{\vdash}
12391225

12401226
.. |vdashfuncinst| mathdef:: \xref{appendix/properties}{valid-funcinst}{\vdash}

0 commit comments

Comments
 (0)