Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2015-10

adding a new token to compiler cause exception

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mohsen

Hi
I need add two token to compiler to implement my ideas. adding first token done but second token cause range check exception in lines like this

if (idtoken in [_EXPORT,_EXTERNAL,_WEAKEXTERNAL,_PUBLIC,_CVAR]) then
ptconst.pas(95,45) Error: range check error in set constructor or
duplicate set element

how to solve it ?

Reply by email

Sven Barth
to Mohsen
"Mohsen" wrote
Hi I need add two token to compiler to implement my ideas. adding first token done but second token cause range check exception in

lines like this

if (idtoken in [_EXPORT,_EXTERNAL,_WEAKEXTERNAL,_PUBLIC,_CVAR]) then ptconst.pas(95,45) Error: range check error in set constructor or

duplicate set element

how to solve it ?

First it would be best if you'd show us what exactly you have changed. Otherwise we won't be able to help you...

Regards,
Sven

Reply by email

MohsenTi
to Sven Barth

I want to add two overloadable operators “>>” and “<<” to use them as “shr” and “shl” ,or writing into and reading from streams and the other functions like those mentioned above.
در تاریخ ۱۳ اکتبر ۲۰۱۵ ۲۲:۲۱، "Sven Barth" نوشت:

Show quoted text 25 lines
Am 13.10.2015 19:59 schrieb "Mohsen" : > > Hi > I need add two token to compiler to implement my ideas. > adding first token done but second token cause range check exception in lines like this > > if (idtoken in [_EXPORT,_EXTERNAL,_WEAKEXTERNAL,_PUBLIC,_CVAR]) then > > ptconst.pas(95,45) Error: range check error in set constructor or duplicate set element > > how to solve it ? First it would be best if you'd show us what exactly you have changed. Otherwise we won't be able to help you... Regards, Sven _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Jonas Maebe
to Mohsen: Hi I need add two token to compiler to implement my ideas. adding first token done but…
Mohsen wrote 6 lines
if (idtoken in [_EXPORT,_EXTERNAL,_WEAKEXTERNAL,_PUBLIC,_CVAR]) then ptconst.pas(95,45) Error: range check error in set constructor or duplicate set element how to solve it ?

Pascal sets can only contain values/enumerations whose ordinal value is <= 255. There are more than 256 tokens already. If you add new tokens at the start, existing tokens may get an ordinal value > 255, so existing set expressions that previously worked may now fail.

The only way to solve that is to remove the items whose ordinal values are > 255 from set expressions and to test for them using the regular '=' operator.

Jonas

Reply by email

Sven Barth
to MohsenTi: I want to add two overloadable operators “>>” and “<<” to use them as “shr”…
"MohsenTi" wrote
I want to add two overloadable operators “>>” and “<<” to use them as

“shr” and “shl” ,or writing into and reading from streams and the other functions like those mentioned above.

Oh dear. You picked yourself the most complicated case in the whole compiler. ">>" and "<<" are automatically converted by the scanner to "shr" and "shl", because someone in the past thought this would ease porting of C-code... And nowadays I have to deal with the consequences related generics.
My tipp: don't use these operators. Period.

Regards,
Sven

Reply by email

Sven Barth
to Jonas Maebe: Pascal sets can only contain values/enumerations whose ordinal value is <= 255. There are…
"Jonas Maebe" wrote 12 lines
On 13/10/15 19:59, Mohsen wrote: > > if (idtoken in [_EXPORT,_EXTERNAL,_WEAKEXTERNAL,_PUBLIC,_CVAR]) then > > ptconst.pas(95,45) Error: range check error in set constructor or > duplicate set element > > how to solve it ? Pascal sets can only contain values/enumerations whose ordinal value is

<= 255. There are more than 256 tokens already. If you add new tokens at the start, existing tokens may get an ordinal value > 255, so existing set expressions that previously worked may now fail.

The only way to solve that is to remove the items whose ordinal values

are > 255 from set expressions and to test for them using the regular '=' operator.

Maybe I should start to work on the support for array constructors and operators once generic functions and dynamic packages are working... :P

Regards,
Sven

Reply by email