Recent

Author Topic: FPC - Recursive call function is interpreter as Result  (Read 742 times)

Milsa

  • Sr. Member
  • ****
  • Posts: 309
FPC - Recursive call function is interpreter as Result
« on: May 11, 2019, 07:56:56 pm »
This code
Code: Pascal  [Select][+][-]
  1. function TInterpreter.Factor: String;
  2. begin
  3.   if FCurToken.TType in [ePLUS, eMINUS] then
  4.   begin
  5.     Result := IntToStr(-StrToInt(Factor)); // <- recursive call
  6.  
is interpreted as
Code: Pascal  [Select][+][-]
  1. function TInterpreter.Factor: String;
  2. begin
  3.   if FCurToken.TType in [ePLUS, eMINUS] then
  4.   begin
  5.     Result := IntToStr(-StrToInt(Result)); // <- recursive call
  6.  
How can I call Factor recursively?
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

ASerge

  • Hero Member
  • *****
  • Posts: 2212
Re: FPC - Recursive call function is interpreter as Result
« Reply #1 on: May 11, 2019, 08:03:53 pm »
Factor()

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: FPC - Recursive call function is interpreter as Result
« Reply #2 on: May 11, 2019, 08:07:02 pm »
I tried this but not worked.

Then I found one mistake in my code. I corrected it.

It already works.

Thak you. You assured me that I was trying correctly.
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

 

TinyPortal © 2005-2018