| 231 | |
| 232 | |
| 233 | static int getposition (lua_State *L, int t, int i) { |
| 234 | int res; |
| 235 | lua_getfenv(L, -1); |
| 236 | lua_rawgeti(L, -1, i); /* get key from pattern's environment */ |
| 237 | lua_gettable(L, t); /* get position from positions table */ |
| 238 | res = lua_tointeger(L, -1); |
| 239 | if (res == 0) { /* key has no registered position? */ |
| 240 | lua_rawgeti(L, -2, i); /* get key again */ |
| 241 | return luaL_error(L, "%s is not defined in given grammar", val2str(L, -1)); |
| 242 | } |
| 243 | lua_pop(L, 2); /* remove environment and position */ |
| 244 | return res; |
| 245 | } |
| 246 | |
| 247 | |
| 248 | /* |
no test coverage detected