PB 5.20 LTS (Linux & Win): apparent bug in the macro parser

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

PB 5.20 LTS (Linux & Win): apparent bug in the macro parser

Post by BorisTheOld »

It appears as if the macro processor, in some situations, is terminating it's scanning too early. It's not satisfying itself that there are no more macro substitutions to be processed.

This code compiles:

Code: Select all

Macro typInt32
  i
EndMacro

x.typInt32   ; x.i
And this code compiles:

Code: Select all

Macro typInt32
  i
EndMacro

Macro Field (DataName, DataType)
  DataName.DataType
EndMacro

Field(x, typInt32)   ; x.i
But this code causes the compiler to complain about a missing structure named, "typInt32".

Code: Select all

Macro typInt32
  i
EndMacro

Macro Field (DataName, DataType)
  DataName.typ#DataType
EndMacro

Field(x, Int32)   ; structure not found: typint32
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 5.20 LTS (Linux & Win): apparent bug in the macro par

Post by Fred »

That's right, such constructs are not supported by the macro preprocessor. Moved to feature request.
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: PB 5.20 LTS (Linux & Win): apparent bug in the macro par

Post by BorisTheOld »

Thanks.

I assume that a macro parameter is parsed against other macros until no more changes occur, then its text is substituted into the macro body. Rather than first substituting the parameters into the macro body, then parsing the macro body until no more changes occur.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Post Reply