Forum Index
Expected end-of-line following value expression

 
Author Message
pjc30943



Joined: 02 Dec 2005

Posted: 22 August 2008, 0:39 AM    Post subject: Expected end-of-line following value expression

For the following code

Code:
      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:
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:
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, 22:25 PM; edited 1 time in total
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Location: Portland, OR

Posted: 22 August 2008, 2:28 AM    Post subject:

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?
Back to top
pjc30943



Joined: 02 Dec 2005

Posted: 22 August 2008, 20:15 PM    Post subject:

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:

returnVar1 = one_over_systemMass * ( thighMass * (xthighCML + xthighCMR) + shankMass)


then it also compiles.


Code:


'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
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Location: Portland, OR

Posted: 26 August 2008, 1:08 AM    Post subject: Re: Expected end-of-line following value expression

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.
Back to top
Display posts from previous:   
Page 1 of 1

 



ZBasic Microcontrollers Home
All content Copyright © 2005, 2006, 2007, 2008 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group