Back-End build process error: expected expression before ';'

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Back-End build process error: expected expression before ';'

Post by pjc30943 »

When y2 = y1, obviously slope = INF. A backend build error arises as a result.
The following is a generic function which demonstrates the problem. Both of the last two lines of the function are required for the error to arise. Additionally, the numerator of 'm' is necessary; if m is instead
1.0 / ( y2 - y1 ), the error does not arise.
The device is a 1280n.

Code: Select all

function A ( byval D as single ) as single
            const C as single = 20.0
            const x2 as single = 20.0, x1 as single = 10.0
	const y2 as single = 1.0, y1 as single = 1.0
	const m as single = ( x2 - x1 ) / ( y2 - y1 )
	const b as single = y2 - (m*y1)
	A = m * abs(D) + b		
	A = A * C 
end function

Code: Select all

biped_joint_controllers_2legs.c:25: error: expected expression before ';' token
make: *** [biped_joint_controllers_2legs.o] Error 1
make: Leaving directory `C:/Program Files/ZBasic/zx_rEudRJ'
biped joint controllers 2legs.bas:21: Internal Error: no means to generate code for expression
Paul
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Re: Back-End build process error: expected expression before

Post by mikep »

This problem actually occurs in the front-end ZBasic compiler which is attempting to calculate the constant expression which evaluates to +INF. This is a problem that should be fixed. The compiler should probably issue warnings for constant expressions that evaluate to -/+INF and NAN.

My question is why do you have a constant expression that is +INF? Any special case calculations involving INF and NAN are probably not supported by ZBasic as they require a lot of special case logic for different expressions.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Back-End build process error: expected expression before

Post by dkinzer »

mikep wrote:The compiler should probably issue warnings for constant expressions that evaluate to -/+INF and NAN.
Quite so. I just finished adding that and modified the native mode code generator to emit a valid value (0.0) when a NaN, infinity or denormalized value is encountered. Of course, this doesn't make the code work but it does avoid the backend compiler errors.
- Don Kinzer
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Post by pjc30943 »

The INF was an inadvertant result when accidentally setting both values to be identical. The error was not well defined, hence the post...
The error occurred not when just evaluating the constant expression, given that a few cases (such as 1.0 / (n-n) = 1.0 / 0.0 ) compiled.

Hence my assumption that this was a compiler bug, versus a front-end evaluation error.
Paul
Post Reply