Comments (8)
Confirmed. Investigating this.
from lua_code_formatter.
goto
is reserved word since Lua 5.2. As this parser is supposed to format Lua 5.3 code it's ok that it fails on 5.1 code that uses goto
as variable.
function mmp.gotoArea (where, number, dashtype, exact)
local goto = maptable[where]
if goto then
mmp.gotoRoom(goto, dashtype)
return
end
end
luac: all_bugs.lua:2: <name> expected near 'goto'
All branches and versions of formatter will fail to parse this code. But in recent versions I've added option to keep unparsed tail (ON by default) so unparsed part is kept.
from lua_code_formatter.
I'm using the 5.1 branch on 5.1 valid code. Is the fix for this to use the keep unparsed code option?
from lua_code_formatter.
Current code from 5.1 branch keeps unparsed tail by default. Problem was in wrong example code, I've just answered at that issue.
(Branch 5.1
assumes that code formatter for Lua 5.3 code is implemented on Lua 5.1.)
from lua_code_formatter.
It's not making sense to me, sorry. It's perfectly valid Lua code per 5.1 interpreter:
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> mmp = {}
> function mmp.gotoArea (where, number, dashtype, exact)
>> local goto = maptable[where]
>> if goto then
>> mmp.gotoRoom(goto, dashtype)
>> return
>> end
>> end
>
Given the formatters corruption of invalid code, I already check that it's valid with Lua before handing it off to the formatter. What should I do now when the formatter thinks the valid code isn't anymore and deletes it?
from lua_code_formatter.
This formatter is for Lua 5.3 code. Using goto
as name is illegal in 5.3 (but legal in 5.1). Formatter keeps unrecognized code by default.
As a workaround to format 5.1 code you can remove goto
from list of reserved words here. And remove label- and goto- constructions from syntax here.
from lua_code_formatter.
Ah ok. What do you think about the 5.1 branch being compatible with 5.1 code by default?
from lua_code_formatter.
I think this is what many people wish. But not going to do it personally. I'll be glad to consult if someone is going to create fork for Lua 5.1 syntax.
from lua_code_formatter.
Related Issues (16)
- Loss of data on invalid input HOT 5
- 5.1 branch does not load correctly anymore HOT 1
- Accept valid lua 5.1 code HOT 4
- Commit disappeared HOT 2
- Incorporate into Textadept? HOT 4
- Unexpect formatting result HOT 2
- Hi~ HOT 6
- Rundundent files left behind by modifications to support Lua 5.1 HOT 1
- Commas get changed to semicolons if max_text_width is small enough HOT 10
- Is it possible to keep shorthand syntax? HOT 2
- How to implement range-based formatting? HOT 6
- How to keep blank lines? HOT 1
- Invalid code is corrupted HOT 2
- How to improve on this formatting? HOT 4
- Customization options HOT 3
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_code_formatter.