I am writing a calculator with the ability to accept new function definitions. Knowing the need for newbies to try recursive functions such as Fibonacci, I would like my calculator to be able to recognize tail-recursive functions with Flex + Bison and convert the code to iterative form. I use Flex and Bison to do the job. If you have any hints or ideas, I welcome them warmly. Thank!
Don't worry about C or C ++ outputs from Flex and Bison. Mostly I want an idea or a hint. Thank.
, ...
def func(args) #stuff return func(otherargs)
, AST - return → func → otherargs, whatevers. , F, F - , PUSH ARGS, GOTO F, . .
, , , , . , .
, , . .
, lexer, , , . - :
func f( a ) if ( a == 0 ) return a return f( a - 1 )
C / . , , , - , , .
, : , . , .
/ (.. Java , ), .
Source: https://habr.com/ru/post/1741660/More articles:Specifications for all Android phones - androidDisplay Ico File in Silverlight 3 - imageИмпортируйте общий объект и вызовите его функции в С++ - c++Gallery of images using jQuery - javascriptдизайн базы данных в движке Google - google-app-engineRollback to a specific point using PostgreSQL - postgresqlHow cookies are processed if you use a proxy server between the client and server in HTTP - cookiesUnable to create MVC project in VS2010 - visual-studio-2010jquery.not () filter - jqueryNo Symfony Form Values - formsAll Articles