文章标题

来源:互联网 发布:c语言判断质数算法 编辑:程序博客网 时间:2024/06/11 02:56

看到网上各种转载修改源码使lua支持中文的,结果试了下发现测试出来有问题,如:

function 为而的() end

stdin:1: ‘(’ expected near ‘)’

这里就会报错,只好改下,就没问题了,如下改后的源码(改动之处已标明,lua5.1/lua5.2/lua5.3均支持)。

#pragma once#include <ctype.h>//////////////////////////////////////////////////////////////////////////////这是中文函数名添加的函数///////////////////////////////////////////////////////////////////////////*开始添加支持中英文变量名*//*因为LS->current是int类型!*/#define USE_CHINESE_NAME   #ifdef USE_CHINESE_NAME   #define isChineseCode(charint)   (charint >= 0x80)      //<<<<<<<<<<<<<<<<<< 第一处#define readxxname(ls) readChinesename(ls)   void readChinesename(LexState *ls){    do    {        if (isChineseCode(ls->current))        {            save_and_next(ls);            //if(ls->current!='(')            if(isChineseCode(ls->current))      //<<<<<<<<<<<<<<<<<<< 第二处            {                save_and_next(ls); //处理了一个中文字符               }        }        else        {            //if(ls->current!='(')            {                save_and_next(ls); //处理英文字符或者下划线               }        }    } while (isChineseCode(ls->current) || ls->current == '_' || isalnum(ls->current));}#else   #define isChineseCode(charint) 0   #define readxxname(ls) readname(ls)   void readname(LexState *ls){    do    {        save_and_next(ls); //处理英文字符或者下划线       } while (isChineseCode(ls->current) || ls->current == '_' || isalnum(ls->current));}#endif  //////////////////////////////////////////////////////////////////////////////以上是中文变量名定义函数////////////////////////////////////////////////////////////////////////////

2016-2-7 新
发现lua5.1.5的mingw64版在windows64 cmd里有问题,有字符缓冲错位的问题,看来以后可以看看什么原因。

0 0
原创粉丝点击