Giter VIP home page Giter VIP logo

Comments (8)

martin-eden avatar martin-eden commented on June 15, 2024

Confirmed. Investigating this.

from lua_code_formatter.

martin-eden avatar martin-eden commented on June 15, 2024

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.

vadi2 avatar vadi2 commented on June 15, 2024

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.

martin-eden avatar martin-eden commented on June 15, 2024

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.

vadi2 avatar vadi2 commented on June 15, 2024

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.

martin-eden avatar martin-eden commented on June 15, 2024

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.

vadi2 avatar vadi2 commented on June 15, 2024

Ah ok. What do you think about the 5.1 branch being compatible with 5.1 code by default?

from lua_code_formatter.

martin-eden avatar martin-eden commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.