You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've faced a problem in reproducing original lua source code from AST. There is a pos field in AST node but is it possible to add optional code context? For example:
I have the following original code:
ifa==3andbthenend
and corresponding AST for it;
{ { { "and", { "eq", { "a",
pos = 4,
tag = "Id"
}, { 3,
pos = 9,
tag = "Number"
},
pos = 4,
tag = "Op"
}, { "b",
pos = 15,
tag = "Id"
},
pos = 4,
tag = "Op"
}, {
pos = 22,
tag = "Block"
},
pos = 1,
tag = "If"
},
pos = 1,
tag = "Block"
}
I want to restore orig code for if condition body. On one hand I believe that I can do it via Breadth-first search on the AST, but some info can be missing: some binary comparation operators transformed in non-revertable AST such as >= & <=, etc. Lua comments are dropped and so on.
So as the result there is a bunch of questions:
Is it possible to add some tag and parser for comments to reflect them in AST?
Maybe we should preserve original code format in AST. I mean not combining commutative operators in same tags (comparation operators, constructions like not a == b, etc)
Is it feasible to add original code context to AST node?
Maybe optionally save whilespaces in AST? Can be useful for code structure (indentation based) linting / static analysis.
The text was updated successfully, but these errors were encountered:
Maybe we should preserve original code format in AST. I mean not combining commutative operators in same tags (comparation operators, constructions like not a == b, etc)
@alexeyknyshev I'm sorry for the delay, but I removed these combinations due to issue #12 and now the AST have all relational operators.
I've faced a problem in reproducing original lua source code from AST. There is a
pos
field in AST node but is it possible to add optional code context? For example:I have the following original code:
and corresponding AST for it;
I want to restore orig code for if condition body. On one hand I believe that I can do it via Breadth-first search on the AST, but some info can be missing: some binary comparation operators transformed in non-revertable AST such as >= & <=, etc. Lua comments are dropped and so on.
So as the result there is a bunch of questions:
not a == b
, etc)The text was updated successfully, but these errors were encountered: