이 같은 테이블 구조의 테이블이 있습니다테이블 루아에서 테이블을 검색
[1] = {
[1] = {
category = "WORD",
cursor = <filtered>,
ptype = "STATEMENT",
ttype = "SERVICE",
value = "service",
<metatable> = <filtered>
},
[2] = {
category = "VARIABLE",
cursor = <filtered>,
ptype = "STATEMENT",
ttype = "IDENTIFIER",
value = "TestService",
<metatable> = <filtered>
},
[3] = {
ttype = "BRACE_BLOCK",
value = {
[1] = { ...
...
[2] = {
[1] = {
category = "WORD",
cursor = <filtered>,
ptype = "STATEMENT",
ttype = "SERVICE",
value = "service",
<metatable> = <filtered>
},
[2] = {
category = "VARIABLE",
cursor = <filtered>,
ptype = "STATEMENT",
ttype = "IDENTIFIER",
value = "HelloWorld",
<metatable> = <filtered>
},
내가 밖으로 정보를 필터링의 ttype와 첫 번째 테이블을 찾는 단순히 루프를 프로그램하고 싶습니다 다음 서비스가 해당 서비스를 시작할 때까지 나머지 토큰을 할당합니다.
local found_service = 0
if found_service == 0 then
for k1, v1 in pairs (parse_tree) do
for i=1,#v1 do
if v1[i].ttype == "SERVICE" then
--Store wanted data in an object
found_service = 1
end
if (found_service == 1 and v1[i].ttype ~= "SERVICE") then
-- ->assign the rest to last found service
end
if found_service == 1 and v1[i].ttype == "SERVICE" then
-- ->Found the next service -->starting over
found_service = 0
end
end
end
end
문제는 내가 색인 난에 붙어 및 V1 [내가] "서비스"는 것을, 그래서 그는 너무, 바로 마지막 경우 절을 입력 : 내 생각은 같다. 첫 번째 if 절 이후에 루프 반복을 어떻게 끝내야합니까? 아니면 이것을 할 수있는 더 좋은 방법이 있습니까?
감사드립니다. Theo
일부 ':: label ::'에 'goto' 사용 – tonypdmtr