Comments (7)
The command line below will simply throw an error if without this commit .
What error?
Do you mean the error is printing nil
on the screen?
Thanks a lot and all best to you. lua-parser is a pretty cool project
π
Thank you for using lua-parser! :)
from lua-parser.
Detail:
[tag] = Localrec
[pos] = 11
[1] = {
[1] = {
[tag] = Id
[pos] = 20
[1] = x
}
}
[tag] = Localrec
[pos] = 11
[1] = {
[tag] = nil -- <<---
[pos] = nil -- <<---
[1] = {
[tag] = Id
[pos] = 20
[1] = x
}
}
from lua-parser.
The error is that when string.format
find the '%s' in its 1st arg refers a nil value, it will simply throw an error.
> return string.format("%s[tag] = %s\n", string.rep(" ", 2), nil)
stdin:1: bad argument #3 to 'format' (string expected, got nil)
stack traceback:
[C]: in function 'format'
stdin:1: in main chunk
[C]: ?
>
from lua-parser.
pp.lua:line:314:
function pp.dump (t, i)
if i == nil then i = 0 end
io.write(string.format("{\n"))
io.write(string.format("%s[tag] = %s\n", string.rep(" ", i+2), t.tag))
io.write(string.format("%s[pos] = %s\n", string.rep(" ", i+2), t.pos))
for k,v in ipairs(t) do
io.write(string.format("%s[%s] = ", string.rep(" ", i+2), tostring(k)))
if type(v) == "table" then
pp.dump(v,i+2)
else
io.write(string.format("%s\n", tostring(v)))
end
end
io.write(string.format("%s}\n", string.rep(" ", i)))
end
And the error below would occur sometimes as the member "tag" and "pos" is not always present in a table which is in the AST ( Sorry for that I did not explain it clearly before).
$ lua parse.lua "x=2;local function x() end"
lua: /usr/share/lua/5.1/lua-parser/pp.lua:314: bad argument #3 to 'format' (string expected, got nil)
stack traceback:
[C]: in function 'format'
/usr/share/lua/5.1/lua-parser/pp.lua:314: in function 'dump'
/usr/share/lua/5.1/lua-parser/pp.lua:319: in function 'dump'
/usr/share/lua/5.1/lua-parser/pp.lua:319: in function 'dump'
parse_str.lua:54: in main chunk
[C]: ?
from lua-parser.
$ lua parse.lua "x=2;local function x() end" lua: /usr/share/lua/5.1/lua-parser/pp.lua:314: bad argument #3 to 'format' (string expected, got nil) stack traceback: [C]: in function 'format' /usr/share/lua/5.1/lua-parser/pp.lua:314: in function 'dump' /usr/share/lua/5.1/lua-parser/pp.lua:319: in function 'dump' /usr/share/lua/5.1/lua-parser/pp.lua:319: in function 'dump' parse_str.lua:54: in main chunk [C]: ?
Thanks! It looks like this is an error specific to Lua version 5.1. I just pushed a commit that should solve this problem. Can you please check whether it works?
from lua-parser.
No problem anymore. Thanks a lot :D
from lua-parser.
No problem anymore. Thanks a lot :D π
Thanks for the report!
from lua-parser.
Related Issues (12)
- can't parse goto HOT 4
- Problem may in lua-parser/parser.lua:binaryOp HOT 7
- help HOT 2
- "attempt to get length of a number value (local 'sfail')" when parsing wrong syntax HOT 2
- parsing error are not properly reported HOT 5
- All tests pass, but fail sometimes ! HOT 2
- problem with fix_str() in parser.lua HOT 6
- [Proposal] Unify tags 'True' and 'False' into 'Boolean' HOT 4
- <= and >= are scanned as the same token HOT 2
- Optional code context linked with ast node HOT 3
- How to generate lua code according to astοΌ HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-parser.