[fpc-devel] C style operator doesn't work with properties in 2.3.1

Martin Friebe fpc at mfriebe.de
Thu Jul 17 12:16:33 CEST 2008


 From my understanding ( the fpc team probably can to more exact):

* lexical level
This would be like a simple "Find and Replace" on the text. This would 
work with anything, as it doesn't know what it is translating.
(It is very similar to a (non-buildin) C-preprocessor)

* parser level
The parser will likely translate the source into a structure of objects
  a := a + 1
becomes
  ObjectAssignmenOp
      LeftHandTerm = ObjVariable "a"
      RightHandTerm = ObjExpression ( ObjAddition: Op1 = Variable "a"; 
Op2= 1 )

If that happens to "+=" then "a+=1"
  ObjectAssignmenOpIncr
      LeftHandTerm = ObjVariable
      RightHandTerm = ObjExpression

if the left hand term is a property, then because it is the left hand 
(which will be assigned to), the lefthand term becomes the property-setter.
The ObjectAssignmenOpIncr then has no reference to the property-getter.


Graeme Geldenhuys wrote:
> On Thu, Jul 17, 2008 at 9:07 AM, Micha Nelissen <micha at neli.hopto.org> wrote:
>   
>> Jonas Maebe wrote:
>>     
>>> Indeed. I've checked the code and properties are explicitly not allowed
>>> for the C-style operators. The reason is that the x+=y is translated into
>>> "x:=x+y" at the parser level rather than at the lexical level. This
>>>       
>> So I guess the obvious question is: would it be risky to change that so it
>> parses it at the lexical level? :-)
>>     
>
>
> My question too....   Would somebody be so kind as to explain the
> difference to me?  As I mentioned before, I'm not a compiler
> developer.
>
>
> Regards,
>  - Graeme -
>
>
> _______________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net/fpgui/
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>   



More information about the fpc-devel mailing list