diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1993-12-22 19:15:16 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1993-12-22 19:15:16 -0200 |
commit | 72f67fa810715220c1134a345903146569417190 (patch) | |
tree | 549f38de6e29fea1f199594998a7a37d7529566d | |
parent | 856004214fdd2ee7380f423cc428b123b89786f6 (diff) | |
download | lua-72f67fa810715220c1134a345903146569417190.tar.gz lua-72f67fa810715220c1134a345903146569417190.tar.bz2 lua-72f67fa810715220c1134a345903146569417190.zip |
eliminacao da funcao findenclosedconstant, cuja tarefa agora
e' realizada pelo analizador lexico
-rw-r--r-- | table.c | 53 | ||||
-rw-r--r-- | table.h | 3 |
2 files changed, 2 insertions, 54 deletions
@@ -3,7 +3,7 @@ | |||
3 | ** Module to control static tables | 3 | ** Module to control static tables |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_table="$Id: $"; | 6 | char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $"; |
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <string.h> | 9 | #include <string.h> |
@@ -116,57 +116,6 @@ int lua_findsymbol (char *s) | |||
116 | } | 116 | } |
117 | 117 | ||
118 | /* | 118 | /* |
119 | ** Given a constant string, eliminate its delimeters (" or '), search it at | ||
120 | ** constant table and return its index. If not found, allocate at end of | ||
121 | ** the table, checking oveflow and return its index. | ||
122 | ** | ||
123 | ** For each allocation, the function allocate a extra char to be used to | ||
124 | ** mark used string (it's necessary to deal with constant and string | ||
125 | ** uniformily). The function store at the table the second position allocated, | ||
126 | ** that represents the beginning of the real string. On error, return -1. | ||
127 | ** | ||
128 | */ | ||
129 | int lua_findenclosedconstant (char *s) | ||
130 | { | ||
131 | int i, j, l=strlen(s); | ||
132 | char *c = calloc (l, sizeof(char)); /* make a copy */ | ||
133 | |||
134 | c++; /* create mark space */ | ||
135 | |||
136 | /* introduce scape characters */ | ||
137 | for (i=1,j=0; i<l-1; i++) | ||
138 | { | ||
139 | if (s[i] == '\\') | ||
140 | { | ||
141 | switch (s[i+1]) | ||
142 | { | ||
143 | case 'n': c[j++] = '\n'; i++; break; | ||
144 | case 't': c[j++] = '\t'; i++; break; | ||
145 | case 'r': c[j++] = '\r'; i++; break; | ||
146 | default : c[j++] = '\\'; break; | ||
147 | } | ||
148 | } | ||
149 | else | ||
150 | c[j++] = s[i]; | ||
151 | } | ||
152 | c[j++] = 0; | ||
153 | |||
154 | for (i=0; i<lua_nconstant; i++) | ||
155 | if (streq(c,lua_constant[i])) | ||
156 | { | ||
157 | free (c-1); | ||
158 | return i; | ||
159 | } | ||
160 | if (lua_nconstant >= MAXCONSTANT-1) | ||
161 | { | ||
162 | lua_error ("lua: constant string table overflow"); | ||
163 | return -1; | ||
164 | } | ||
165 | lua_constant[lua_nconstant++] = c; | ||
166 | return (lua_nconstant-1); | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | ** Given a constant string, search it at constant table and return its index. | 119 | ** Given a constant string, search it at constant table and return its index. |
171 | ** If not found, allocate at end of the table, checking oveflow and return | 120 | ** If not found, allocate at end of the table, checking oveflow and return |
172 | ** its index. | 121 | ** its index. |
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | ** Module to control static tables | 2 | ** Module to control static tables |
3 | ** TeCGraf - PUC-Rio | 3 | ** TeCGraf - PUC-Rio |
4 | ** $Id: $ | 4 | ** $Id: table.h,v 1.1 1993/12/17 18:41:19 celes Exp roberto $ |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #ifndef table_h | 7 | #ifndef table_h |
@@ -26,7 +26,6 @@ extern int lua_nfile; | |||
26 | 26 | ||
27 | 27 | ||
28 | int lua_findsymbol (char *s); | 28 | int lua_findsymbol (char *s); |
29 | int lua_findenclosedconstant (char *s); | ||
30 | int lua_findconstant (char *s); | 29 | int lua_findconstant (char *s); |
31 | void lua_markobject (Object *o); | 30 | void lua_markobject (Object *o); |
32 | char *lua_createstring (char *s); | 31 | char *lua_createstring (char *s); |