浏览代码

names generated by yacc (starting with "yy") are changed to start with
"luaY_", to avoid name clashes with hosts using yacc.

Roberto Ierusalimschy 30 年之前
父节点
当前提交
27ae8432b6
共有 3 个文件被更改,包括 20 次插入16 次删除
  1. 9 10
      lex.c
  2. 9 4
      makefile
  3. 2 2
      opcode.h

+ 9 - 10
lex.c

@@ -1,10 +1,9 @@
-char *rcs_lex = "$Id: lex.c,v 2.20 1995/10/25 13:05:51 roberto Exp roberto $";
+char *rcs_lex = "$Id: lex.c,v 2.21 1995/11/16 20:46:24 roberto Exp roberto $";
  
  
 
 
 #include <ctype.h>
 #include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 #include <string.h>
+#include <stdio.h>
 
 
 #include "mem.h"
 #include "mem.h"
 #include "tree.h"
 #include "tree.h"
@@ -144,7 +143,7 @@ static int read_long_string (void)
 }
 }
 
 
 
 
-int yylex (void)
+int luaY_lex (void)
 {
 {
   float a;
   float a;
   static int linelasttoken = 0;
   static int linelasttoken = 0;
@@ -176,12 +175,12 @@ int yylex (void)
         *yytextLast = 0;
         *yytextLast = 0;
 	if (lua_strcmp(yytext, "debug") == 0)
 	if (lua_strcmp(yytext, "debug") == 0)
 	{
 	{
-	  yylval.vInt = 1;
+	  luaY_lval.vInt = 1;
 	  return DEBUG;
 	  return DEBUG;
         }
         }
 	else if (lua_strcmp(yytext, "nodebug") == 0)
 	else if (lua_strcmp(yytext, "nodebug") == 0)
 	{
 	{
-	  yylval.vInt = 0;
+	  luaY_lval.vInt = 0;
 	  return DEBUG;
 	  return DEBUG;
         }
         }
 	return WRONGTOKEN;
 	return WRONGTOKEN;
@@ -203,7 +202,7 @@ int yylex (void)
             return WRONGTOKEN;
             return WRONGTOKEN;
           save_and_next();  /* pass the second ']' */
           save_and_next();  /* pass the second ']' */
           *(yytextLast-2) = 0;  /* erases ']]' */
           *(yytextLast-2) = 0;  /* erases ']]' */
-          yylval.vWord = luaI_findconstantbyname(yytext+2);
+          luaY_lval.vWord = luaI_findconstantbyname(yytext+2);
           return STRING;
           return STRING;
         }
         }
 
 
@@ -263,7 +262,7 @@ int yylex (void)
         }
         }
         next();  /* skip the delimiter */
         next();  /* skip the delimiter */
         *yytextLast = 0;
         *yytextLast = 0;
-        yylval.vWord = luaI_findconstantbyname(yytext);
+        luaY_lval.vWord = luaI_findconstantbyname(yytext);
         return STRING;
         return STRING;
       }
       }
 
 
@@ -286,7 +285,7 @@ int yylex (void)
         *yytextLast = 0;
         *yytextLast = 0;
         res = findReserved(yytext);
         res = findReserved(yytext);
         if (res) return res;
         if (res) return res;
-        yylval.pNode = lua_constcreate(yytext);
+        luaY_lval.pNode = lua_constcreate(yytext);
         return NAME;
         return NAME;
       }
       }
 
 
@@ -327,7 +326,7 @@ fraction:
 	      ea*=ea;
 	      ea*=ea;
 	    }
 	    }
           }
           }
-          yylval.vFloat = a;
+          luaY_lval.vFloat = a;
           return NUMBER;
           return NUMBER;
         }
         }
 
 

+ 9 - 4
makefile

@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.15 1995/10/17 18:16:58 roberto Exp roberto $
+# $Id: makefile,v 1.16 1995/11/10 17:56:06 roberto Exp roberto $
 
 
 #configuration
 #configuration
 
 
@@ -47,14 +47,19 @@ lualib.a : $(LIBOBJS)
 liblua.so.1.0 : lua.o
 liblua.so.1.0 : lua.o
 	ld -o liblua.so.1.0 $(LUAOBJS)
 	ld -o liblua.so.1.0 $(LUAOBJS)
 
 
+y.tab.c y.tab.h  : lua.stx
+	yacc++ -d lua.stx
 
 
-parser.c : lua.stx
-	yacc++ -d lua.stx ; mv -f y.tab.c parser.c ; mv -f y.tab.h parser.h
+parser.c : y.tab.c
+	sed -e 's/yy/luaY_/g' y.tab.c > parser.c
+
+parser.h : y.tab.h
+	sed -e 's/yy/luaY_/g' y.tab.h > parser.h
 
 
 clear	:
 clear	:
 	rcsclean
 	rcsclean
 	rm -f *.o
 	rm -f *.o
-	rm -f parser.c parser.h
+	rm -f parser.c parser.h y.tab.c y.tab.h
 	co lua.h lualib.h luadebug.h
 	co lua.h lualib.h luadebug.h
 
 
 % : RCS/%,v
 % : RCS/%,v

+ 2 - 2
opcode.h

@@ -1,6 +1,6 @@
 /*
 /*
 ** TeCGraf - PUC-Rio
 ** TeCGraf - PUC-Rio
-** $Id: opcode.h,v 3.13 1995/10/17 11:58:41 roberto Exp roberto $
+** $Id: opcode.h,v 3.14 1995/10/25 13:05:51 roberto Exp roberto $
 */
 */
 
 
 #ifndef opcode_h
 #ifndef opcode_h
@@ -146,7 +146,7 @@ char   *lua_strdup (char *l);
 
 
 void    lua_setinput   (Input fn);	/* from "lex.c" module */
 void    lua_setinput   (Input fn);	/* from "lex.c" module */
 char   *lua_lasttext   (void);		/* from "lex.c" module */
 char   *lua_lasttext   (void);		/* from "lex.c" module */
-int     yylex (void);		        /* from "lex.c" module */
+int     luaY_lex (void);	        /* from "lex.c" module */
 void    lua_parse      (TFunc *tf);	/* from "lua.stx" module */
 void    lua_parse      (TFunc *tf);	/* from "lua.stx" module */
 void	luaI_codedebugline (int line);  /* from "lua.stx" module */
 void	luaI_codedebugline (int line);  /* from "lua.stx" module */
 void    lua_travstack (int (*fn)(Object *));
 void    lua_travstack (int (*fn)(Object *));