aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1993-12-22 19:15:16 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1993-12-22 19:15:16 -0200
commit72f67fa810715220c1134a345903146569417190 (patch)
tree549f38de6e29fea1f199594998a7a37d7529566d
parent856004214fdd2ee7380f423cc428b123b89786f6 (diff)
downloadlua-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.c53
-rw-r--r--table.h3
2 files changed, 2 insertions, 54 deletions
diff --git a/table.c b/table.c
index 8b425e2f..62ad696a 100644
--- a/table.c
+++ b/table.c
@@ -3,7 +3,7 @@
3** Module to control static tables 3** Module to control static tables
4*/ 4*/
5 5
6char *rcs_table="$Id: $"; 6char *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*/
129int 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.
diff --git a/table.h b/table.h
index 1941fb28..ca246dc6 100644
--- a/table.h
+++ b/table.h
@@ -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
28int lua_findsymbol (char *s); 28int lua_findsymbol (char *s);
29int lua_findenclosedconstant (char *s);
30int lua_findconstant (char *s); 29int lua_findconstant (char *s);
31void lua_markobject (Object *o); 30void lua_markobject (Object *o);
32char *lua_createstring (char *s); 31char *lua_createstring (char *s);