I am trying to create a grammar for parsing RTF files. At some points I need to store some information in the scope of the grammar. I know, that I could use inherited attributes, but this would worsen readability.
So I asked myself if instance member variables of the grammar could solve my problem and, if yes, how should I use them in my grammar?
For example, I need to keep track of the active codepage for character conversion. Is it good practice to have an int codepage
inside my grammar struct?
What I further want is, to call some function for putting and popping the state variables on a stack. I think I will combine the state information in a RtfState class, which I can extend as needed. What would be the best way to call member functions of the grammar struct?