Balanced round brackets in my language grammar


I’m an absolute newbie when it comes to TextMate, regex or anything like that, I only discovered atom a few weeks ago … Absolutely loving it so far!

Unfortunately the language I’m coding in is not very well known at all and therefore doesn’t have a language package for atom, which means I had to create one myself. I surprised myself with how far I was able to get, however I’ve come to a point in the grammar development where I just can’t seem to progress … and there doesn’t seem to be a lot of help material about this on the internet, as most people probably just code in languages that are supported.

One of the big problems I have is supporting balanced brackets. Consider this example:
Constant = 1 AnotherConstant = (1) SomeValue = TAN(Array(1))

TAN() is a function in my language, and I want to make all functions including their brackets the same colour, however my grammar will currently just recognise the first closing bracket after the opening bracket as the end of the function. I think I need to do something with recursion to fix this, but every single thing I found on the web resulted in errors within atom. I found this here, but it didn’t really work for me:

Am I on the right track?

Another issue I have is that integer literals in the above example aren’t highlighted as such, even though they do get highlighted in the rest of my code. As soon as they’re within brackets, my grammar doesn’t recognise them.

Also here is the GitHub repo of my language grammar: