blob: 57de6458a63a5c9847789c6622cef8e9e77272bc (
plain)
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
|
% Copyright (c) 1991: Marcel Roelofs and Peter Gragert
% University of Twente, Enschede, The Netherlands
% @@(#) rtangle.ch (91/03/11)
@x
@u
@<Include files@>@;
@<Common code for \.{WEAVE} and \.{TANGLE}@>@;
@<Typedef declarations@>@;
@<Global variables@>@;
@y
@u
#define NEWLINES_IN_MACROS
@<Include files@>@;
@<Common code for \.{WEAVE} and \.{TANGLE}@>@;
@<Typedef declarations@>@;
@<Global variables@>@;
@z
@x
if (isdigit(c) || c=='\\' || c=='.') @<Get a constant@>@;/*spider*/
else if (isalpha(c) || c=='_' || c=='$') @<Get an identifier@>@;/*spider*/
else if (c=='\'' || c=='\"') @<Get a string@>@;/*spider*/
@y
if (isdigit(c)) @<Get a constant@>@;/*spider*/
else if (isalpha(c) || c=='_' || c=='!') @<Get an identifier@>@;/*spider*/
else if (c=='\"') @<Get a string@>@;/*spider*/
@z
@x
@ @<Get an identifier@>= {/*spider*/
id_first=--loc;
while (isalpha(*++loc) || isdigit(*loc) || *loc=='_');
if (*loc=='$') while (isdigit(*++loc)||*loc=='$');
/* make room for \$\$ and \$nnn suffixes */
id_loc=loc; return(identifier);
}
@y
@ @<Get an identifier@>= {/*spider*/
id_first=--loc;
if (c=='!') ++loc;
while (isalpha(*++loc) || isdigit(*loc) || *loc=='_' || *loc=='!')
if (*loc=='!') ++loc;
id_loc=loc; return(identifier);
}
@z
@x
@ \cee\ strings and character constants, delimited by double and single
quotes, respectively, can contain newlines or instances of their own
delimiters if they are protected by a backslash. We follow this
convention, but do not allow the string to be longer than |longest_name|.
@<Get a string@>= {/*spider*/
ASCII delim = c; /* what started the string */
@#
/* if it's not a single-character literal, it's a tick mark or an |at_sign| */
if (delim=='\'' && (loc+1>=limit ||
(*loc != '\\' && *loc!=at_sign && loc[1]!='\'') ||
(*loc=='\\' && (loc+2>=limit||loc[2]!='\'')) ||
(*loc==at_sign &&
(loc+2>=limit||loc[1]!=at_sign||loc[2]!='\''))
)) goto mistake;
id_first = mod_text+1;
id_loc = mod_text; *++id_loc=delim;
while (1) {
if (loc>=limit) {
if(*(limit-1)!='\\') {
err_print("! String didn't end"); loc=limit; break;
@.String didn't end@>
}
if(get_line()==0) {
err_print("! Input ended in middle of string"); loc=buffer; break;
@.Input ended in middle of string@>
}
else if (++id_loc<=mod_text_end) *id_loc=@`\n'; /* will print as
\.{"\\\\\\n"} */
}
if ((c=*loc++)==delim) {
if (++id_loc<=mod_text_end) *id_loc=c;
break;
}
if (c=='\\') {
if (loc>=limit) continue;
if (++id_loc<=mod_text_end) *id_loc = '\\';
c=*loc++;
}
if (++id_loc<=mod_text_end) *id_loc=c;
}
if (id_loc>=mod_text_end) {
printf("\n! String too long: ");
@.String too long@>
ASCII_write(mod_text+1,25);
printf("..."); mark_error;
}
id_loc++;
return(string);
}
@y
@ \cee\ strings are delimited by double quotes and must be restricted
to one line. Double quotes in strings must be doubled and we allow no
string to be longer than |longest_name|.
@<Get a string@>= {/*spider*/
ASCII delim = c; /* what started the string */
@#
id_first = mod_text+1;
id_loc = mod_text; *++id_loc=delim;
while (1) {
if (loc>=limit) {
err_print("! String didn't end"); loc=limit;
@.String didn't end@>
if (get_line()==0) {
err_print("! Input ended in middle of string"); loc=buffer;
@.Input ended in middle of string@>
}
break;
}
if ((c=*loc++)==delim) {
if (++id_loc<=mod_text_end) *id_loc=c;
if (*loc==delim) loc++;
else break;
}
if (++id_loc<=mod_text_end) *id_loc=c;
}
if (id_loc>=mod_text_end) {
printf("\n! String too long: ");
@.String too long@>
ASCII_write(mod_text+1,25);
printf("..."); mark_error;
}
id_loc++;
return(string);
}
@z
|