1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
*** master/spider.web.old Mon Jul 3 12:46:05 1989
--- master/spider.web Thu Jul 20 19:00:04 1989
***************
*** 1532,1537 ****
--- 1532,1541 ----
each scrap is true, the whole production will fire.
If we're called upon to make a scrap underlined or reserved, we'll add
to |trans[pos]|.
+
+ If a category is negated we add an extra clause to make
+ sure nothing matches the zero category, since {\tt WEAVE} assumes
+ no production ever matches a scrap with category zero.
#<Process a single category#>=
field[pos]=$i ## save this field to compare RHS
#<Set |negation|, and remove leading |"!"| from |$i| if necessary#>
***************
*** 1540,1548 ****
cat = $i
categories[cat]=1 ## remember |cat| is a category
if (negation==0) {
! test[pos]=sprintf("(pp+%d)->cat==SP_%s",pos-1,cat)
} else {
! test[pos]=sprintf("(pp+%d)->cat!=SP_%s",pos-1,cat)
}
#<Update the record of the rightmost occurrence of category |cat|#>
#<Advance |pos|, making the new |trans[pos]| empty#>
--- 1544,1553 ----
cat = $i
categories[cat]=1 ## remember |cat| is a category
if (negation==0) {
! test[pos]=sprintf("(pp+%d)->cat==SP_%s",pos-1,cat)
} else {
! test[pos]=sprintf("((pp+%d)->cat!=SP_%s && (pp+%d)->cat != 0)",\
! pos-1,cat,pos-1)
}
#<Update the record of the rightmost occurrence of category |cat|#>
#<Advance |pos|, making the new |trans[pos]| empty#>
***************
*** 1551,1556 ****
--- 1556,1565 ----
categories are separated by vertical bars.
We have to make the test for these things a disjunction, but
processing is more or less like the processing for a single category.
+
+ If a list of alternatives is negated we add an extra clause to make
+ sure nothing matches the zero category, since {\tt WEAVE} assumes
+ no production ever matches a scrap with category zero.
#<Process a list of alternative categories#>=
field[pos]=$i ## save this field to compare RHS
#<Set |negation|, and remove leading |"!"| from |$i| if necessary#>
***************
*** 1557,1563 ****
if (negation==0) {
test[pos]="(" ## open for a list of good alternatives
} else {
! test[pos]="!(" ## open for a list of bad alternatives
}
#<Strip stars from |$i| (if any) and add appropriate
translations to |trans[pos]|#>
--- 1566,1573 ----
if (negation==0) {
test[pos]="(" ## open for a list of good alternatives
} else {
! temp=sprintf("(pp+%d)->cat==0",pos-1)
! test[pos]="!(" temp "||" ## open for a list of bad alternatives
}
#<Strip stars from |$i| (if any) and add appropriate
translations to |trans[pos]|#>
***************
*** 1635,1644 ****
#<Forget this production#>
}
! # Wild cards are easy to process
#<Process a category wild card#>=
field[pos]=$i ## save this field to compare RHS
! test[pos]="(1)" ## anything matches
highwildcard=pos ## we don't really need this?
#<Advance |pos|, making the new |trans[pos]| empty#>
--- 1645,1655 ----
#<Forget this production#>
}
! # Wild cards are easy to process, but we do have to remember that
! not even a wild card matches a scrap of category zero.
#<Process a category wild card#>=
field[pos]=$i ## save this field to compare RHS
! test[pos]=sprintf("(pp+%d)->cat!=0",pos-1) ## anything nonzero matches
highwildcard=pos ## we don't really need this?
#<Advance |pos|, making the new |trans[pos]| empty#>
|