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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <ctotok.h>
include "../lib/ids.h"
# MATCH -- Match look up tables. The command reads
# match this_one (to) that one
procedure match
char token[SZ_LINE]
int tok
short f_ref[2]
short c_ref[IDS_MAXGCOLOR+1]
short frames[IDS_MAXIMPL+1]
short colors[IDS_MAXGCOLOR+1]
short nextcolor
int nchar, i, val, ctoi()
int ltype
include "cv.com"
begin
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
if ( (tok == TOK_IDENTIFIER) && (token[1] == 'o') ) {
ltype = IDS_OUTPUT_LUT
} else {
ltype = IDS_FRAME_LUT
# "Push back" the token
call reset_scan
call gargtok (tok, token, SZ_LINE)
}
# All this parsing tells us why YACC and LEX were invented
# Use "i" to tell if have parsed something useful
i = -1
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
if ((tok == TOK_IDENTIFIER) && (token[1] == 'f')) {
i = 1
call cv_frame (token[2], frames)
if (frames[1] == ERR)
return
} else if (tok == TOK_NUMBER) {
i = 1
nchar = ctoi (token, i, val)
if ((val < 1) || (val > cv_maxframes)) {
call eprintf ("Invalid frame specification: %d\n")
call pargi (val)
return
} else {
frames[1] = val
frames[2] = IDS_EOD
}
} else if (ltype == IDS_FRAME_LUT) {
call eprintf ("missing frame arguement\n")
return
} else
frames[1] = IDS_EOD
# default first color argument to all colors for both FRAME and OUTPUT
# tables...means make all colors the same.
colors[1] = IDS_EOD # default all colors
# Advance if previous token was useful
if ( i != -1 ) {
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
}
# Look for a color
if ((tok == TOK_IDENTIFIER) && (token[1] == 'c')) {
call cv_color (token[2], colors)
if (colors[1] == ERR)
return
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
}
# look for fill word "to"
if ((tok == TOK_IDENTIFIER) && (token[1] == 't')) {
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
}
# if FRAME LUT, we default frame to first frame to be changed.
# if OUTPUT LUT, frame is irrelevant
i = -1
if (tok == TOK_IDENTIFIER) {
if (token[1] == 'f')
i = 2
else if (token[1] != 'c') {
call eprintf ("Unexpected argument: %s\n")
call pargstr (token)
return
}
} else if (tok == TOK_NUMBER)
i = 1
# if ltype is OUTPUT lut, don't care about frame type, but can't
# omit it...so default to EOD
f_ref[1] = IDS_EOD
f_ref[2] = IDS_EOD
if (ltype == IDS_FRAME_LUT) {
if (i == -1) {
f_ref[1] = frames[1]
} else {
nchar = ctoi (token, i, val)
if ((val < 1) || (val > cv_maxframes)) {
call eprintf ("Invalid frame specification: %d\n")
call pargi (val)
return
}
f_ref[1] = val
}
}
# Only thing left should be the reference color.
# If found a frame before, advance the token.
if (i != -1) {
call gargtok (tok, token, SZ_LINE)
call strlwr (token)
}
if ((tok != TOK_NEWLINE) && (tok != TOK_IDENTIFIER)) {
call eprintf ("Unexpected input: %s\n")
call pargstr (token)
return
}
c_ref[1] = IDS_EOD
if (tok == TOK_IDENTIFIER) {
if (token[1] != 'c') {
call eprintf ("Unexpected input (color required): %s\n")
call pargstr (token)
return
} else {
call cv_color (token[2], c_ref)
if (c_ref[1] == ERR)
return
}
}
if (c_ref[1] != IDS_EOD)
call cvmatch (ltype, f_ref, c_ref, frames, colors)
else {
# No specific color for reference. If no color specified
# to copy into, do all.
c_ref[2] = IDS_EOD
if ( colors[1] == IDS_EOD ) {
colors[1] = IDS_RED
colors[2] = IDS_GREEN
colors[3] = IDS_BLUE
colors[4] = IDS_EOD
}
# Match for each color given in "colors"
for ( i = 1 ; colors[i] != IDS_EOD; i = i + 1) {
nextcolor = colors[i+1]
colors[i+1] = IDS_EOD
c_ref[1] = colors[i]
call cvmatch (ltype, f_ref, c_ref, frames, colors[i])
colors[i+1] = nextcolor
}
}
end
|