|
@@ -1,6 +1,6 @@
|
|
%{
|
|
%{
|
|
|
|
|
|
-char *rcs_luastx = "$Id: lua.stx,v 3.43 1997/01/31 14:27:11 roberto Exp roberto $";
|
|
|
|
|
|
+char *rcs_luastx = "$Id: lua.stx,v 3.44 1997/02/13 16:18:39 roberto Exp roberto $";
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
@@ -50,8 +50,6 @@ static TaggedString *localvar[MAXLOCALS]; /* store local variable names */
|
|
static int nlocalvar=0; /* number of local variables */
|
|
static int nlocalvar=0; /* number of local variables */
|
|
|
|
|
|
#define MAXFIELDS FIELDS_PER_FLUSH*2
|
|
#define MAXFIELDS FIELDS_PER_FLUSH*2
|
|
-static Word fields[MAXFIELDS]; /* fieldnames to be flushed */
|
|
|
|
-static int nfields=0;
|
|
|
|
|
|
|
|
int lua_debug = 0;
|
|
int lua_debug = 0;
|
|
|
|
|
|
@@ -103,22 +101,11 @@ static void code_word_at (Byte *p, int n)
|
|
memcpy(p, &w, sizeof(Word));
|
|
memcpy(p, &w, sizeof(Word));
|
|
}
|
|
}
|
|
|
|
|
|
-static void push_field (Word name)
|
|
|
|
-{
|
|
|
|
- if (nfields < MAXFIELDS)
|
|
|
|
- fields[nfields++] = name;
|
|
|
|
- else
|
|
|
|
- yyerror ("too many fields in nested constructors");
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static void flush_record (int n)
|
|
static void flush_record (int n)
|
|
{
|
|
{
|
|
- int i;
|
|
|
|
if (n == 0) return;
|
|
if (n == 0) return;
|
|
- code_byte(STORERECORD);
|
|
|
|
|
|
+ code_byte(STOREMAP);
|
|
code_byte(n);
|
|
code_byte(n);
|
|
- for (i=0; i<n; i++)
|
|
|
|
- code_word(fields[--nfields]);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void flush_list (int m, int n)
|
|
static void flush_list (int m, int n)
|
|
@@ -161,6 +148,17 @@ static void add_varbuffer (Long var)
|
|
yyerror ("variable buffer overflow");
|
|
yyerror ("variable buffer overflow");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void code_string (Word w)
|
|
|
|
+{
|
|
|
|
+ code_byte(PUSHSTRING);
|
|
|
|
+ code_word(w);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void code_constant (TaggedString *s)
|
|
|
|
+{
|
|
|
|
+ code_string(luaI_findconstant(s));
|
|
|
|
+}
|
|
|
|
+
|
|
static void code_number (float f)
|
|
static void code_number (float f)
|
|
{
|
|
{
|
|
Word i;
|
|
Word i;
|
|
@@ -477,8 +475,7 @@ function : FUNCTION funcname body
|
|
funcname : var { $$ =$1; init_func(); }
|
|
funcname : var { $$ =$1; init_func(); }
|
|
| varexp ':' NAME
|
|
| varexp ':' NAME
|
|
{
|
|
{
|
|
- code_byte(PUSHSTRING);
|
|
|
|
- code_word(luaI_findconstant($3));
|
|
|
|
|
|
+ code_constant($3);
|
|
$$ = 0; /* indexed variable */
|
|
$$ = 0; /* indexed variable */
|
|
init_func();
|
|
init_func();
|
|
add_localvar(luaI_createfixedstring("self"));
|
|
add_localvar(luaI_createfixedstring("self"));
|
|
@@ -605,9 +602,8 @@ expr : '(' expr ')' { $$ = $2; }
|
|
| NUMBER { code_number($1); $$ = 0; }
|
|
| NUMBER { code_number($1); $$ = 0; }
|
|
| STRING
|
|
| STRING
|
|
{
|
|
{
|
|
- code_byte(PUSHSTRING);
|
|
|
|
- code_word($1);
|
|
|
|
- $$ = 0;
|
|
|
|
|
|
+ code_string($1);
|
|
|
|
+ $$ = 0;
|
|
}
|
|
}
|
|
| NIL {code_byte(PUSHNIL); $$ = 0; }
|
|
| NIL {code_byte(PUSHNIL); $$ = 0; }
|
|
| functioncall { $$ = $1; }
|
|
| functioncall { $$ = $1; }
|
|
@@ -723,12 +719,13 @@ ffieldlist1 : ffield {$$=1;}
|
|
}
|
|
}
|
|
;
|
|
;
|
|
|
|
|
|
-ffield : NAME '=' expr1
|
|
|
|
- {
|
|
|
|
- push_field(luaI_findconstant($1));
|
|
|
|
- }
|
|
|
|
|
|
+ffield : ffieldkey '=' expr1
|
|
;
|
|
;
|
|
|
|
|
|
|
|
+ffieldkey : '[' expr1 ']'
|
|
|
|
+ | NAME { code_constant($1); }
|
|
|
|
+ ;
|
|
|
|
+
|
|
lfieldlist : /* empty */ { $$ = 0; }
|
|
lfieldlist : /* empty */ { $$ = 0; }
|
|
| lfieldlist1 lastcomma { $$ = $1; }
|
|
| lfieldlist1 lastcomma { $$ = $1; }
|
|
;
|
|
;
|
|
@@ -762,9 +759,8 @@ var : singlevar { $$ = $1; }
|
|
}
|
|
}
|
|
| varexp '.' NAME
|
|
| varexp '.' NAME
|
|
{
|
|
{
|
|
- code_byte(PUSHSTRING);
|
|
|
|
- code_word(luaI_findconstant($3));
|
|
|
|
- $$ = 0; /* indexed variable */
|
|
|
|
|
|
+ code_constant($3);
|
|
|
|
+ $$ = 0; /* indexed variable */
|
|
}
|
|
}
|
|
;
|
|
;
|
|
|
|
|