behaviour on error

behaviour on error

there are various errors that may occur - syntax errors, type coercion errors (using a number where a string is expected), arithmetic errors (divide by 0), and possibly others (overflow?)I guess the error message, line number etc. is written to stderr. What output is expected to be written to the output file when these errors occur? Is the output ignored, oor should it contain all output statements up to the point of the line that is in error?

9 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Just to hopefully clarify my question, what is the allowable output of

var a = 0;var b = 1;var c = 2;d = 2abc; // syntax erroroutput(a);output(b);output(c);

Is it allowed for any of a b or c to be output, even though they come after the syntax error?

That's an interesting question. The rules seems to suggest that we have to generate an error. If the error isn't generated then it seems that the (statement) order isn't respected. Still seems like we should be able to generate both the syntax error and the output statements.

My guess is, execution must stop when an error is encountered.

The problem says, "Syntax errors should stop the execution with an error indicating the line number and the statement that caused the syntax error."

Hi,
Yes, the execution should stop on encountering an error and the output till that point and the error statement should be printed in the output file.

Thanks
-Rama

So do we _have_ to write the output even if there is a syntax error, and only output up to the location of the error?In other words - the interpreter has to behave as if executed sequentially?This is a shame. I can imagine schemes where syntax checking is partially done upfront, before any execution is done and output produced, or that statements are executed out of order so the syntax error is discovered much later than corresponding output.

Hi,
Note that we are writing a parallel implementation of a parser and formula interpreter. A serial versionwould have executed these statements sequentially. Since we are looking for an interpreter implementation, we would want output to be generated up to the point where execution succeeded without errors. You can do upfront anlysis and discover errors or execute statements out-of-order in parallel and discover/ addresserrors on the fly when you encounter.

Thanks
-Rama

Thanks. If understand what you say, then the results will be as if each statement were executed sequentially.(Of course, the interpreter is not executing sequentially, but it has to have the same affect as if it were.)In my example above, the only allowed output is none - since all output statements come after the syntax error.Can you confirm this?

Just think about the following situation. You have to create a highly-optimized version of an existing interpreted language. Think about JavaScript.The developer writes JavaScript code that considers a specific execution order. However, the parallelized interpreter tries to execute instructions in parallel to increase throughput. The parallelized interpreter has to guarantee correctness. Thus, you need the same effect as if it were executing sequentially in the output.A syntax error stops the execution. No more results have to be shown after the syntax error. However, all the results that had to appear before the syntax error in the sequential input should appear.Cheers,Gaston

Gastón C. Hillar

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi