flex icon indicating copy to clipboard operation
flex copied to clipboard

verify if function is a definition or a call ?

Open sahil-ecosmob opened this issue 2 years ago • 1 comments

Hello Everyone. I want to search for a function in a specific .c file using flex and then verify if the found result is a function definition or a function call ? I am able to search the function call without any problem but trying to verify if it's a call or a definition. I can write rules for the same but it can get complicated very fast as I'll have to take care of a lot of border cases. Is there any inbuilt functionality in flex that can help me achieve the same. Thanks in advance.

sahil-ecosmob avatar Jul 15 '22 06:07 sahil-ecosmob

This use case crosses over to the job of a parser like bison. A flex scanner tokenizes your input file, according to your rules, them a parser determines what different sequences of tokens mean, again according to your rules. A function definition and call use many of the same tokens just in a different sequence, so this is a parsing problem.

To keep your code same, use flex to recognize that a word is a type name, numeric literal, identifier, operator, etc. Then use bison or another parser generator to recognize and interpret token sequences.

On Fri, Jul 15, 2022, 02:06 sahil-ecosmob @.***> wrote:

Hello Everyone. I want to search for a function in a specific .c file using flex and then verify if the found result is a function definition or a function call ? I am able to search the function call without any problem but trying to verify if it's a call or a definition. I can write rules for the same but it can get complicated very fast as I'll have to take care of a lot of border cases. Is there any inbuilt functionality in flex that can help me achieve the same. Thanks in advance.

— Reply to this email directly, view it on GitHub https://github.com/westes/flex/issues/534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVJXIJZ6NS2D4KJGHTKVNLVUD5UZANCNFSM53UPC65A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Mightyjo avatar Jul 15 '22 14:07 Mightyjo