I'm doing a semactic analyzer and I need to know when there is a function in the code. I know that a function begins with an id and later there is a '(' So, in my array of elements I have this:
['id', '(', ')', '{', 'id', '(', 'lit-str', ')', ';', 'id', '(', 'lit-str', ')', ';', 'id', '(', '!', 'lit-int', ')', ';', 'id', '(', ')', ';', '}']
All 'id' followed by a '(' are functions. So, I need to find all this ocurrences. Is there some method to find all these 'id' and '(' in order to count them?
Not all the codes are exactly the same, some are bigger.
I alredy tried to do this with and if
(if 'id' + '(' in array: print(count))
But this only count the first occurrence.