lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


sunshilong:

On Wed, Jan 27, 2021 at 2:10 AM 孙世龙 sunshilong <sunshilong369@gmail.com> 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.