[fpc-devel] Incomplete docs on operator precedence / Question about actual precedence

Martin Frb lazarus at mfriebe.de
Mon Feb 3 02:42:21 CET 2014


http://www.freepascal.org/docs-html/ref/refch12.html#x120-13000012

lists
> Table 12.1: Precedence of operators
>
> Operator 	Precedence 	Category
> ------------------------------------------------------------------------
> 	
> ------------------------------------------------------------------------
> 	
> ------------------------------------------------------------------------
> Not, @ 	Highest (first) 	Unary operators
> * / div mod and shl shr as << >> 	Second 	Multiplying operators
> + - or xor 	Third 	Adding operators
> = <> < > <= >= in is 	Lowest (Last) 	relational operators
>


This does not include:
^ deref
- unary minus
. accessing a member of a class/record (not unary)

Assuming they are in the "Highest" group, then they have same precedence 
as "@".
In an expression containing a mix, I would assume a left to right order.

However this does not compile (project1.lpr(6,10) Error: Illegal qualifier)
   {$T+}  var i: integer
   if @i^ = 0 then ;

If left to right had taken place, then the above would be equal to
   if (@i)^ = 0 then ;
And that compiles.

So it appears that ^ takes precedence over @ ? Or is this a bug?

It also appears that the "." takes precedence over @
@Object.Foo
is equal to
@(Object.Foo)
well otherwise it could not compile

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140203/36084898/attachment.html>


More information about the fpc-devel mailing list