Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Unicode标识符支持构建Lua5.2.3?_Unicode_Lua - Fatal编程技术网

如何使用Unicode标识符支持构建Lua5.2.3?

如何使用Unicode标识符支持构建Lua5.2.3?,unicode,lua,Unicode,Lua,所以我想在Lua中使用Unicode标识符。我遵循了这个指南: 但这会导致以下错误: In file included from lua.h:16:0, from luac.c:15: luaconf.h:553:27: error: expected identifier or ‘(’ before numeric constant #define isalnum(zeich) (((0x80&zeich)||isalnum(zeich))&

所以我想在Lua中使用Unicode标识符。我遵循了这个指南:

但这会导致以下错误:

In file included from lua.h:16:0,
                 from luac.c:15:
luaconf.h:553:27: error: expected identifier or ‘(’ before numeric constant
 #define isalnum(zeich) (((0x80&zeich)||isalnum(zeich))&&zeich!=-1)
                           ^
luaconf.h:553:38: error: expected ‘)’ before ‘||’ token
 #define isalnum(zeich) (((0x80&zeich)||isalnum(zeich))&&zeich!=-1)
                                      ^
luaconf.h:553:55: error: expected ‘)’ before ‘&&’ token
 #define isalnum(zeich) (((0x80&zeich)||isalnum(zeich))&&zeich!=-1)
                                                       ^
luaconf.h:550:27: error: expected identifier or ‘(’ before numeric constant
 #define isalpha(zeich) (((0x80&zeich)||isalpha(zeich))&&zeich!=-1)
                           ^
luaconf.h:550:38: error: expected ‘)’ before ‘||’ token
 #define isalpha(zeich) (((0x80&zeich)||isalpha(zeich))&&zeich!=-1)
                                      ^
luaconf.h:550:55: error: expected ‘)’ before ‘&&’ token
 #define isalpha(zeich) (((0x80&zeich)||isalpha(zeich))&&zeich!=-1)
                                                       ^
luaconf.h:555:26: error: expected identifier or ‘(’ before ‘!’ token
 #define isdigit(zeich) ((!(0x80&zeich)&&isdigit(zeich))&&zeich!=-1)
                          ^
luaconf.h:555:56: error: expected ‘)’ before ‘&&’ token
 #define isdigit(zeich) ((!(0x80&zeich)&&isdigit(zeich))&&zeich!=-1)
                                                        ^
luaconf.h:558:26: error: expected identifier or ‘(’ before ‘!’ token
 #define isspace(zeich) ((!(0x80&zeich)&&isspace(zeich))&&zeich!=-1)
                          ^
luaconf.h:558:56: error: expected ‘)’ before ‘&&’ token
 #define isspace(zeich) ((!(0x80&zeich)&&isspace(zeich))&&zeich!=-1)
                                                        ^
 <builtin>: recipe for target 'luac.o' failed
在lua.h:16:0中包含的文件中,
来自luac.c:15:
luaconf.h:553:27:错误:应为标识符或数值常量前的“(”
#定义isalnum(zeich)(((0x80&zeich)| | isalnum(zeich))和&zeich!=-1)
^
luaconf.h:553:38:错误:在“||”标记之前应为“')
#定义isalnum(zeich)(((0x80&zeich)| | isalnum(zeich))和&zeich!=-1)
^
luaconf.h:553:55:错误:在“&&”标记之前应为“')
#定义isalnum(zeich)(((0x80&zeich)| | isalnum(zeich))和&zeich!=-1)
^
luaconf.h:550:27:错误:应为标识符或数值常量前的“(”
#定义isalpha(zeich)(((0x80&zeich)| | isalpha(zeich))和&zeich!=-1)
^
luaconf.h:550:38:错误:在“||”标记之前应为“')
#定义isalpha(zeich)(((0x80&zeich)| | isalpha(zeich))和&zeich!=-1)
^
luaconf.h:550:55:错误:在“&&”标记之前应为“')
#定义isalpha(zeich)(((0x80&zeich)| | isalpha(zeich))和&zeich!=-1)
^
luaconf.h:555:26:错误:应为标识符或“(”在“!”之前)标记
#定义isdigit(zeich)((!(0x80&zeich)&&isdigit(zeich))&&zeich!=-1)
^
luaconf.h:555:56:错误:在“&&”标记之前应为“')
#定义isdigit(zeich)((!(0x80&zeich)&&isdigit(zeich))&&zeich!=-1)
^
luaconf.h:558:26:错误:应为标识符或“(”在“!”之前)标记
#定义isspace(zeich)((!(0x80&zeich)和isspace(zeich))&&zeich!=-1)
^
luaconf.h:558:56:错误:在“&&”标记之前应为“')
#定义isspace(zeich)((!(0x80&zeich)和isspace(zeich))&&zeich!=-1)
^
:目标'luac.o'的配方失败

我尝试用您所做的修改构建Lua5.2.3。我得到的第一个错误是:

In file included from luac.c:211:
/usr/include/ctype.h:212:1: error: expected identifier or '('
isalnum(int _c)
下一个错误是你的问题

查看
luac.c
我看到
ctype.h
包含在文件末尾(第211行);在lua标题之后。但是,为了构建一个支持unicode的lua,您所做的是重新定义ctype函数

可以通过移动从第211行开始的两行来修复错误:

#include <ctype.h>
#include <stdio.h>
#包括
#包括
到文件的顶部


但请注意:我确实尝试了使用这些指令构建的Lua二进制文件,但它不接受utf8标识符。

这是一个老问题

我解决了这个问题,在llex.c中更改了一些行

解决方案:

*查找静态int llex函数,并在其中查找(;;)的循环

*和:将(;;)的循环中的原始默认开关替换为:

default:{/*使lua接受unicode标识符*/
如果(((0x80&ls->current)| isalpha(ls->current))和&ls->current!=-1)){//lislalpha(ls->current)){/*标识符或保留字*/
t字符串*ts;
做{
保存_和_next(ls);
}而(((0x80&ls->current)| isalnum(ls->current))和&ls->current!=-1));//lislalnum(ls->current));//*put(“
default: {  /*make lua accept unicode identifiers*/
    if ((((0x80&ls->current)||isalpha(ls->current))&&ls->current!=-1)) {  //lislalpha(ls->current)) {  /* identifier or reserved word? */
      TString *ts;
      do {
        save_and_next(ls);           
      } while ((((0x80&ls->current)||isalnum(ls->current))&&ls->current!=-1)); //lislalnum(ls->current)); /*puts(" <<\n");*/
      ts = luaX_newstring(ls, luaZ_buffer(ls->buff),
                              luaZ_bufflen(ls->buff));
      seminfo->ts = ts;
      if (isreserved(ts))  /* reserved word? */
        return ts->tsv.extra - 1 + FIRST_RESERVED;
      else {
        return TK_NAME;
      }
    }
    else {  /* single-char tokens (+ - / ...) */
      int c = ls->current;
      next(ls);
      return c;
    }
  }