eliminacao da funcao findenclosedconstant, cuja tarefa agora

e' realizada pelo analizador lexico
This commit is contained in:
Roberto Ierusalimschy 1993-12-22 19:15:16 -02:00
parent 856004214f
commit 72f67fa810
2 changed files with 2 additions and 54 deletions

53
table.c
View File

@ -3,7 +3,7 @@
** Module to control static tables
*/
char *rcs_table="$Id: $";
char *rcs_table="$Id: table.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $";
#include <stdlib.h>
#include <string.h>
@ -115,57 +115,6 @@ int lua_findsymbol (char *s)
return lua_ntable++;
}
/*
** Given a constant string, eliminate its delimeters (" or '), search it at
** constant table and return its index. If not found, allocate at end of
** the table, checking oveflow and return its index.
**
** For each allocation, the function allocate a extra char to be used to
** mark used string (it's necessary to deal with constant and string
** uniformily). The function store at the table the second position allocated,
** that represents the beginning of the real string. On error, return -1.
**
*/
int lua_findenclosedconstant (char *s)
{
int i, j, l=strlen(s);
char *c = calloc (l, sizeof(char)); /* make a copy */
c++; /* create mark space */
/* introduce scape characters */
for (i=1,j=0; i<l-1; i++)
{
if (s[i] == '\\')
{
switch (s[i+1])
{
case 'n': c[j++] = '\n'; i++; break;
case 't': c[j++] = '\t'; i++; break;
case 'r': c[j++] = '\r'; i++; break;
default : c[j++] = '\\'; break;
}
}
else
c[j++] = s[i];
}
c[j++] = 0;
for (i=0; i<lua_nconstant; i++)
if (streq(c,lua_constant[i]))
{
free (c-1);
return i;
}
if (lua_nconstant >= MAXCONSTANT-1)
{
lua_error ("lua: constant string table overflow");
return -1;
}
lua_constant[lua_nconstant++] = c;
return (lua_nconstant-1);
}
/*
** Given a constant string, search it at constant table and return its index.
** If not found, allocate at end of the table, checking oveflow and return

View File

@ -1,7 +1,7 @@
/*
** Module to control static tables
** TeCGraf - PUC-Rio
** $Id: $
** $Id: table.h,v 1.1 1993/12/17 18:41:19 celes Exp roberto $
*/
#ifndef table_h
@ -26,7 +26,6 @@ extern int lua_nfile;
int lua_findsymbol (char *s);
int lua_findenclosedconstant (char *s);
int lua_findconstant (char *s);
void lua_markobject (Object *o);
char *lua_createstring (char *s);