06.11.2013 Views

The Basis System - Weapons and Complex Integration - Lawrence ...

The Basis System - Weapons and Complex Integration - Lawrence ...

The Basis System - Weapons and Complex Integration - Lawrence ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if you have trouble tracking down a syntax error, don’t confine your search to the immediate<br />

neighborhood where it was detected. It could have been many lines previous.<br />

10.2.2 Semantic Errors<br />

Many times the <strong>Basis</strong> diagnostics for semantic errors make it very easy to discover what was<br />

wrong. For example, the statement<br />

b = c + a<br />

produces the following diagnostic (when debug is yes):<br />

parasgn2: Shape mismatch between source <strong>and</strong> target in<br />

assignment or append.<br />

Right side (source) true dimension= 2 true shape= 10 10<br />

Left side (target) true dimension= 0 true shape=<br />

parasgn: error in assignment to variable named ’b’.<br />

Writing traceback info to file trace24589x<br />

Returned to user input level.<br />

Clearly the problem is that the right side is a 10 by 10 array, <strong>and</strong> the left side b is a scalar, so this<br />

is an illegal assignment.<br />

Sometimes the traceback information can be useful; if you examine the traceback file (in this case<br />

trace24589x), you will find that it contains<br />

Here is the information I have on where you were:<br />

<strong>The</strong> error occurred in the assignment or append statement:<br />

b = expression<br />

<strong>The</strong> following lines contain clues(not facts) about the r. h. s.<br />

c+a<br />

Parser’s action number = 3(ASSIGN ), program counter = 26.<br />

Frequently a semantic error will be detected inside a function, or perhaps nested inside several<br />

function calls. <strong>The</strong> error printout may concern a variable or parameter local to the function where<br />

execution is taking place, <strong>and</strong> the name of the variable seems totally off the wall. For instance,<br />

consider the declaration <strong>and</strong> function call:<br />

integer z ( 2 , 4 , 5 )<br />

call f ( z )<br />

This function call produced the following error diagnostic:<br />

46 Chapter 10. Error Recovery <strong>and</strong> Diagnosis

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!