我正在寻找一种非常快速的方法来渲染带有SDL2三层的平铺地图.我正在使用SDL_RenderCopy,但它很慢......
我的词法分析器和解析器中存在问题.
首先,在我的词法分析器中,我有这样一句话:
"if" beginScope(stOTHER); return IF;
Run Code Online (Sandbox Code Playgroud)
在我的解析器中:
stmt: IF '(' exp ')' stmts
...
stmts: stmt
| '{' stmt_list '}'
| '{' '}'
Run Code Online (Sandbox Code Playgroud)
在这样的代码中:
if(sth) {
dosth;
}
if(other) {
doothersth;
}
Run Code Online (Sandbox Code Playgroud)
beginScope将被调用两次,因为(我认为)Bison不知道if语句的结尾在哪里,所以当它找到IF令牌时,他将其作为if语句的结尾,并再次读取它开始另一个if声明......
请帮我...
我有这样的功能stoi:
static int *stoi(const char *c) {
int *r = new int[2];
r[1] = sscanf(c, "%d", &r[0]);
return r;
}
Run Code Online (Sandbox Code Playgroud)
c = "a5"例如,当我举出时,它不起作用.
当我付出时c = "543336535",它有效.
但是当我给c = "45sdfff-sdbsdf esg5sq4f"它它将返回时r[0] = 45,我不希望这样,因为...之后有一些非数字字符45...
我只希望我的函数读取一个只有数字的字符串.