Expected end-of-line following value expression

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

Expected end-of-line following value expression

Post by pjc30943 »

For the following code

Code: Select all

		dim test1 as single = 1.0
		dim test2 as single = 1.0
		dim test3 as single = 1.0
		dim test4 as single = 1.0
		dim returnVar as single
		returnVar = 1.0 * ( 1.0 * (test1 + test2) + 1.0 * (test3 + test4) )
why might I get the error "Expected end-of-line following value expression"?

EDIT: turns out this has to be in the context of the function, as anything in the last two lines--including the addition shown above--will yield that error.
Commenting out either of the last two lines results in compilation.
Reducing the complexity of one of the lines results in compilation; eg.

Code: Select all

returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass)
Most likely it's a simple syntax mistake on my part. Here's the actual function:

Code: Select all

public function findCM(byval mode as byte, byref returnVar1 as single, byref returnVar2 as single) as byte

		dim xkneeL as single, ykneeL as single
		dim xthighCML as single, ythighCML as single
		dim xshankCML as single, yshankCML as single
		dim xkneeR as single, ykneeR as single
		dim xthighCMR as single, ythighCMR as single
		dim xshankCMR as single, yshankCMR as single
		
		xthighCML = thighCMdist*sin(DEG_TO_RAD*thighAngle(Lleg))
		ythighCML = -thighCMdist*cos(DEG_TO_RAD*thighAngle(Lleg))		
		xkneeL = 2.0*xthighCML
		ykneeL = 2.0*ythighCML
		xshankCML = xkneeL + shankCMdist*sin(DEG_TO_RAD*(thighAngle(Lleg) + kneeAngle(Lleg)))
		yshankCML = ykneeL - shankCMdist*cos(DEG_TO_RAD*(thighAngle(Lleg) + kneeAngle(Lleg)))
		
		xthighCMR = thighCMdist*sin(DEG_TO_RAD*thighAngle(Rleg))		
		ythighCMR = -thighCMdist*cos(DEG_TO_RAD*thighAngle(Rleg))		
		xkneeR = 2.0*xthighCMR
		ykneeR = 2.0*ythighCMR
		xshankCMR = xkneeR + shankCMdist*sin(DEG_TO_RAD*(thighAngle(Rleg) + kneeAngle(Rleg)))
		yshankCMR = ykneeR - shankCMdist*cos(DEG_TO_RAD*(thighAngle(Rleg) + kneeAngle(Rleg)))
		
		returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass * (xshankCML + xshankCMR) )
		returnVar2 = one_over_systemMass * ( thighMass * (ythighCML + ythighCMR) + shankMass * (yshankCML + yshankCMR) )
	
end function
Last edited by pjc30943 on 22 August 2008, 15:25 PM, edited 1 time in total.
Paul
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

Apparently, there's more context that is needed to reveal the problem. It compiles fine here if I add some missing constant and array definitions. Could you send me the full source code?

Also, which version of the compiler are you using?
- Don Kinzer
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Post by pjc30943 »

dkinzer wrote:Apparently, there's more context that is needed to reveal the problem. It compiles fine here if I add some missing constant and array definitions. Could you send me the full source code?

Also, which version of the compiler are you using?

2.5.5

The following complete code exhibits the error.
It is a nonsensical test case that uses nonititialized vars, etc..
If either of the last two lines are commented out, the program compiles.
If, for example, the 2nd to last line is simplified to be

Code: Select all

returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass)
then it also compiles.

Code: Select all


'demonstrates a problem where one of two lines in the findCM function cause a compilation error.  
'----------- Configurations ---------\\
Option TargetCPU zx1280n
Option ExtRamConfig On
Option PortPinEncoding Off
Option TaskStackMargin 12
'~ Option RamSize 64*1024-Register.RamStart
'~ Option HeapSize 500
public tickPerS as single		'holds main clock frequency
public SPerTick as single		'1 / tickPerS
public three60_over_tickPerS as single
'-------------------------------------//


'-------------------------------------

public const thighLen 		as single = 46.0	'cm from joint to joint of upper leg
public const shankLen  		as single = 43.0	'lower leg

public const thighMass 		as single = 2.0		'in kg
public const shankMass 		as single = 2.0
public const bodyMass 		as single = 1.0
public const systemMass		as single = 2.0 * (thighMass + shankMass) + bodyMass		'total mass of the biped
public const one_over_systemMass as single = 1.0 / systemMass

'-------------------------------------

Sub Main()
End Sub


public function findCM(byval mode as byte, byref returnVar1 as single, byref returnVar2 as single) as byte
	dim xkneeL as single, ykneeL as single
	dim xthighCML as single, ythighCML as single
	dim xshankCML as single, yshankCML as single
	dim xkneeR as single, ykneeR as single
	dim xthighCMR as single, ythighCMR as single
	dim xshankCMR as single, yshankCMR as single
	
	returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass * (xshankCML + xshankCMR) )
	returnVar2 = one_over_systemMass * ( thighMass * (ythighCML + ythighCMR) + shankMass * (yshankCML + yshankCMR) )
end function
Paul
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Expected end-of-line following value expression

Post by dkinzer »

pjc30943 wrote:why might I get the error "Expected end-of-line following value expression"?
It turns out that the line beginning with returnVar1 = had an end-of-line consisting of a carriage return only. The current release of the ZBasic compiler's parser does not handle this EOL style; it replaces a lone carriage return with a space thus causing the confusion. The ZBasic IDE handles the old Macintosh end-of-line correctly so there is no visual indication of what the problem might be.

The compiler has now been modified to handle all three end-of-line combinations: CR only, LF only, and CR-LF (previously, only two of the three were supported). This should be available in the next public release.
- Don Kinzer
Post Reply