How to subscribe to parse tree

Hey, I’m new in CodeMirror, can you please help?
I want to highlight specific tags, depending on tag text. For example, I have variable tags, starting from @ sign: @box + @triangle. How can I highlight box and triangle in a different color? How can I subscribe from my code to the events when @box or @triangle were removed?
I have a grid and formula input field in my application. In formula I can reference cells of my grid. I need to set the same color for the cell border and the cell reference in formula input field.
Thank you in advance!