Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
Hi, list
      As the title, It seems impossible to achieve this goal since Lua
stops to do more work after encountering the first error.
      Am I missing something?

      Thank you for your attention to this matter.

Best regards
Sunshilong
Reply | Threaded
Open this post in threaded view
|

Re:Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

suote127
Maybe luac can do it.

——Suote127
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
>Maybe luac can do it.
As far as I can see, luac could not achieve this goal.

As per the documentation(https://www.lua.org/manual/5.3/luac.html#),
which says that:
luac is the Lua compiler. It translates programs written in the Lua
programming language into binary files containing precompiled chunks
that can be later loaded and executed.

So I can draw the conclusion that Luac would stop to compile after
encountering the first error as Lua does.

Sunshilong


On Mon, Jan 25, 2021 at 4:02 PM Suote127 <[hidden email]> wrote:
>
> Maybe luac can do it.
>
> ——Suote127
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
After I have done some tests, I find the conclusion((i.e Luac would
stop to compile after
encountering the first error as Lua does) aforementioned in last email
is correct.

On Mon, Jan 25, 2021 at 4:16 PM 孙世龙 sunshilong <[hidden email]> wrote:

>
> >Maybe luac can do it.
> As far as I can see, luac could not achieve this goal.
>
> As per the documentation(https://www.lua.org/manual/5.3/luac.html#),
> which says that:
> luac is the Lua compiler. It translates programs written in the Lua
> programming language into binary files containing precompiled chunks
> that can be later loaded and executed.
>
> So I can draw the conclusion that Luac would stop to compile after
> encountering the first error as Lua does.
>
> Sunshilong
>
>
> On Mon, Jan 25, 2021 at 4:02 PM Suote127 <[hidden email]> wrote:
> >
> > Maybe luac can do it.
> >
> > ——Suote127
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Victor Bombi
In reply to this post by 孙世龙 sunshilong
https://studio.zerobrane.com/

> On January 25, 2021 at 8:19 AM 孙世龙 sunshilong <[hidden email]> wrote:
>
>
> Hi, list
>       As the title, It seems impossible to achieve this goal since Lua
> stops to do more work after encountering the first error.
>       Am I missing something?
>
>       Thank you for your attention to this matter.
>
> Best regards
> Sunshilong
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Luiz Henrique de Figueiredo
In reply to this post by suote127
> Maybe luac can do it.

luac uses the Lua library, just like lua does. Therefore, it stops
compilation at the first error.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Les Farrell
Luacheck might do the job. https://github.com/mpeterv/luacheck

On Mon, 25 Jan 2021 at 12:04, Luiz Henrique de Figueiredo <[hidden email]> wrote:
> Maybe luac can do it.

luac uses the Lua library, just like lua does. Therefore, it stops
compilation at the first error.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

suote127
But,according to the manual,most of these tools  do not support Lua5.4.
Maybe they can also work well on Lua 5.4.But,why not add this feature to original Lua?It seems useful.
("original Lua":I mean the Lua version that builds by Lua Team.Sorry for my poor English)

----Suote127
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
In reply to this post by Les Farrell
>Luacheck might do the job.
Luacheck is a choice, but it seems not a good one for me.
Firstly, Luacheck could not support the command that I register to Lua
by lua_register.
Secondly, Luacheck is written in Lua other than C/C++/C#, which is
hard to integrate into our project (C/C++/C#).

Thank you for your attention to my question.

On Mon, Jan 25, 2021 at 8:16 PM Les Farrell <[hidden email]> wrote:
>
> Luacheck might do the job. https://github.com/mpeterv/luacheck
>
> On Mon, 25 Jan 2021 at 12:04, Luiz Henrique de Figueiredo <[hidden email]> wrote:
>>
>> > Maybe luac can do it.
>>
>> luac uses the Lua library, just like lua does. Therefore, it stops
>> compilation at the first error.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
Background:
I register a lot of self-defined commands for Lua by lua_register.
I want to tell the users all the errors in their Lua scripts other
than one by one.

Thank you for your attention to my question.

On Mon, Jan 25, 2021 at 8:45 PM 孙世龙 sunshilong <[hidden email]> wrote:

>
> >Luacheck might do the job.
> Luacheck is a choice, but it seems not a good one for me.
> Firstly, Luacheck could not support the command that I register to Lua
> by lua_register.
> Secondly, Luacheck is written in Lua other than C/C++/C#, which is
> hard to integrate into our project (C/C++/C#).
>
> Thank you for your attention to my question.
>
> On Mon, Jan 25, 2021 at 8:16 PM Les Farrell <[hidden email]> wrote:
> >
> > Luacheck might do the job. https://github.com/mpeterv/luacheck
> >
> > On Mon, 25 Jan 2021 at 12:04, Luiz Henrique de Figueiredo <[hidden email]> wrote:
> >>
> >> > Maybe luac can do it.
> >>
> >> luac uses the Lua library, just like lua does. Therefore, it stops
> >> compilation at the first error.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Javier Guerra Giraldez
In reply to this post by 孙世龙 sunshilong
On Mon, 25 Jan 2021 at 07:46, 孙世龙 sunshilong <[hidden email]> wrote:
> Firstly, Luacheck could not support the command that I register to Lua
> by lua_register.

add a .luacheckrc file

> Secondly, Luacheck is written in Lua other than C/C++/C#, which is
> hard to integrate into our project (C/C++/C#).

you can call a Lua VM just to do the check


--
Javier
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
>> Secondly, Luacheck is written in Lua other than C/C++/C#, which is
>> hard to integrate into our project (C/C++/C#).
>you can call a Lua VM just to do the check
Lua stops to do more work after encountering the first the error,
eg: if there is a Lua script as the below one, Lua stop compilation
after reporting a syntax error at line 3 other than reporting all the
syntax errors in this code snippet.

a = {}
b = true;
n1+n2
n3+n5
n6+n9

On Mon, Jan 25, 2021 at 10:08 PM Javier Guerra Giraldez
<[hidden email]> wrote:

>
> On Mon, 25 Jan 2021 at 07:46, 孙世龙 sunshilong <[hidden email]> wrote:
> > Firstly, Luacheck could not support the command that I register to Lua
> > by lua_register.
>
> add a .luacheckrc file
>
> > Secondly, Luacheck is written in Lua other than C/C++/C#, which is
> > hard to integrate into our project (C/C++/C#).
>
> you can call a Lua VM just to do the check
>
>
> --
> Javier
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Javier Guerra Giraldez
On Tue, 26 Jan 2021 at 01:29, 孙世龙 sunshilong <[hidden email]> wrote:
>
> >> Secondly, Luacheck is written in Lua other than C/C++/C#, which is
> >> hard to integrate into our project (C/C++/C#).
> >you can call a Lua VM just to do the check
> Lua stops to do more work after encountering the first the error,

I meant a LuaVM to call luacheck.


--
Javier
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Gé Weijers
In reply to this post by 孙世龙 sunshilong
On Sun, Jan 24, 2021 at 11:20 PM 孙世龙 sunshilong <[hidden email]> wrote:
>
> Hi, list
>       As the title, It seems impossible to achieve this goal since Lua
> stops to do more work after encountering the first error.
>       Am I missing something?

The problem is that there is no good and efficient strategy to modify
the input ('fix' the error) so the compiler is guaranteed to be able
to continue and analyze the rest of the program in a meaningful way.
What do you do, insert a symbol, delete a symbol, ...? If the 'fix' is
wrong you're likely to end up with a cascade of error messages that
are completely missing the mark.

In the days when compiling a program took a long time there was a good
reason to pay attention to recovering from compilation errors so you
could fix multiple errors between compiler runs, but compiling a Lua
program takes milliseconds on any reasonable machine so it's probably
not worth the trouble to modify the parser to do something clever
enough to recover from most errors.

--

Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
Gé Weijers, Thank you for your detailed explanation.
My understanding of this question is at a different level with your
generous help.

I agree with what all you said indeed.

I still have a question, how C/C++ achieve this goal (i.e. reporting
multiple errors after running a compilation)?

Thanks to all of you.

Best regards
sunshilong

On Wed, Jan 27, 2021 at 2:39 AM Gé Weijers <[hidden email]> wrote:

>
> On Sun, Jan 24, 2021 at 11:20 PM 孙世龙 sunshilong <[hidden email]> wrote:
> >
> > Hi, list
> >       As the title, It seems impossible to achieve this goal since Lua
> > stops to do more work after encountering the first error.
> >       Am I missing something?
>
> The problem is that there is no good and efficient strategy to modify
> the input ('fix' the error) so the compiler is guaranteed to be able
> to continue and analyze the rest of the program in a meaningful way.
> What do you do, insert a symbol, delete a symbol, ...? If the 'fix' is
> wrong you're likely to end up with a cascade of error messages that
> are completely missing the mark.
>
> In the days when compiling a program took a long time there was a good
> reason to pay attention to recovering from compilation errors so you
> could fix multiple errors between compiler runs, but compiling a Lua
> program takes milliseconds on any reasonable machine so it's probably
> not worth the trouble to modify the parser to do something clever
> enough to recover from most errors.
>
> --
> Gé
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Russell Haley


On Tue, Jan 26, 2021 at 5:10 PM 孙世龙 sunshilong <[hidden email]> wrote:
Gé Weijers, Thank you for your detailed explanation.
My understanding of this question is at a different level with your
generous help.

I agree with what all you said indeed.

I still have a question, how C/C++ achieve this goal (i.e. reporting
multiple errors after running a compilation)?

Lua and all the "checking code" that has ever been written probably comes in at 10 MB (an incoherent guess obviously). The LLVM source code is over 1.2 GB. 


Thanks to all of you.

Best regards
sunshilong

On Wed, Jan 27, 2021 at 2:39 AM Gé Weijers <[hidden email]> wrote:
>
> On Sun, Jan 24, 2021 at 11:20 PM 孙世龙 sunshilong <[hidden email]> wrote:
> >
> > Hi, list
> >       As the title, It seems impossible to achieve this goal since Lua
> > stops to do more work after encountering the first error.
> >       Am I missing something?
>
> The problem is that there is no good and efficient strategy to modify
> the input ('fix' the error) so the compiler is guaranteed to be able
> to continue and analyze the rest of the program in a meaningful way.
> What do you do, insert a symbol, delete a symbol, ...? If the 'fix' is
> wrong you're likely to end up with a cascade of error messages that
> are completely missing the mark.
>
> In the days when compiling a program took a long time there was a good
> reason to pay attention to recovering from compilation errors so you
> could fix multiple errors between compiler runs, but compiling a Lua
> program takes milliseconds on any reasonable machine so it's probably
> not worth the trouble to modify the parser to do something clever
> enough to recover from most errors.
>
> --
> Gé
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Sean Conner
In reply to this post by 孙世龙 sunshilong
It was thus said that the Great 孙世龙 sunshilong once stated:
> Gé Weijers, Thank you for your detailed explanation.
> My understanding of this question is at a different level with your
> generous help.
>
> I agree with what all you said indeed.
>
> I still have a question, how C/C++ achieve this goal (i.e. reporting
> multiple errors after running a compilation)?

  Not very well.  They kept going, but the errors accumulated so you would
get a cascade of errors.  A minor example:

src/callbacks.c: In function `handle_aflinks':
src/callbacks.c:707: error: syntax error before "char"
src/callbacks.c:705: warning: empty body in an if-statement
src/callbacks.c: At top level:
src/callbacks.c:724: error: syntax error before '}' token
make: *** [src/callbacks.o] Error 1

  Two errors, one warning.  The actual error?  A missing opening '{'.  The
conventional wisdom was to ignore all reported errors except for the first
one.  

  -spc
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

孙世龙 sunshilong
Great Sean Conner said that.
>Not very well.  They kept going, but the errors accumulated so you would
>get a cascade of errors.
Yes, a cascade of errors may report.
What about modifying the code of Lua and letting it use the same
method to report multiple errors like C/C++ (after a complete
complication)?

Thanks to all of you.
On Wed, Jan 27, 2021 at 9:42 AM Sean Conner <[hidden email]> wrote:

>
> It was thus said that the Great 孙世龙 sunshilong once stated:
> > Gé Weijers, Thank you for your detailed explanation.
> > My understanding of this question is at a different level with your
> > generous help.
> >
> > I agree with what all you said indeed.
> >
> > I still have a question, how C/C++ achieve this goal (i.e. reporting
> > multiple errors after running a compilation)?
>
>   Not very well.  They kept going, but the errors accumulated so you would
> get a cascade of errors.  A minor example:
>
> src/callbacks.c: In function `handle_aflinks':
> src/callbacks.c:707: error: syntax error before "char"
> src/callbacks.c:705: warning: empty body in an if-statement
> src/callbacks.c: At top level:
> src/callbacks.c:724: error: syntax error before '}' token
> make: *** [src/callbacks.o] Error 1
>
>   Two errors, one warning.  The actual error?  A missing opening '{'.  The
> conventional wisdom was to ignore all reported errors except for the first
> one.
>
>   -spc
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Francisco Olarte
In reply to this post by 孙世龙 sunshilong
sunshilong:

On Wed, Jan 27, 2021 at 2:10 AM 孙世龙 sunshilong <[hidden email]> wrote:
> I still have a question, how C/C++ achieve this goal (i.e. reporting
> multiple errors after running a compilation)?

They more or less check point the state and roll back to a check point.

I've done something like save state at the start of a "line" ( real
line in my case, it can be the start of a statement, or the expression
on an if  / for / while ), compile the line ( after determining its
end, may be a newline, a semicolon, a closing parentheses ), modify
state if right, rollback if wrong, go on.

It works well when the errors do not affect things below, like you are
modifying an expression and made a typo, not so well when you miss a
declaration or a control structure, which as pointed previously tends
to cascade.

They also do tricks like resetting when they know they are at top
level and similar things, but it is quite normal to get a couple
hundred errors, fix one and reduce them to two.

With "classic" tools, like separated editor and compiler, this aids in
many cases even with fast compilations, as you have a save-launch
compilation - read and  locate break on your flow which can benefit
from locating multiple errors. With IDE it aids less, as it can take
care of that stuff and let you just navigate the error.

And as said before, in the old times the "compiling" cycle took ages.
I did not have to go through the dreaded operators, but I still
remember when I started taking the deck of FORTRAN cards, compiling
it, which was not that slow once they percolated to the fromt of the
card reader, waiting for the listing, which was normally done by the
time I re-boxed my cards and  walked to the line printer, and going
back with them to start fixing. Compilation cycle, counted fom when I
stood up to got to the machine room to when I sat down was easily 5
minutes. One thing for sure, I was a much more careful coder, and even
know many people are surprised as how little compilation errors I
normally get on the first run.

Francisco Olarte.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to point out all the errors in an already written Lua script? Is there a IDE that could achieve this goal?

Roberto Ierusalimschy
In reply to this post by Sean Conner
>   Two errors, one warning.  The actual error?  A missing opening '{'.  The
> conventional wisdom was to ignore all reported errors except for the first
> one.  

My favorite is the reverse of that one, an extra open '{'. Often,
I write a new function and copy its header from the .c to the .h,
forgetting to change the '{' to ';'. In a large .c file, that simple
error makes gcc generate lots of warnings and errors. You have to
skip dozens of warnings just to get to the first error.

-- Roberto