I have some complicated expressions with loads of nested commands which are difficult to work with. To solve this I wrote a parser using pgfparser which creates the expressions for me. I can then copy the output back in to LaTeX and it outputs what I need.
I was wondering if I could automate this. I can store the text (a sequence of commands) in a variable but then I can't find a way to run the commands in the variable
The parser itself is not of much interest but as a mwe this is a simplified version of what I have:
\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage{pgf}
\usepgfmodule{parser}
\pgfparserdef{mweparser}{initial}{\meaning [}{\textbackslash overline\{}
\pgfparserdef{mweparser}{initial}{\meaning ]}{\}}
\pgfparserdef{mweparser}{initial}{\meaning A}{A}
\pgfparserdef{mweparser}{initial}{subscript character _}{\_\{\pgfparserswitch{subscript}}
\pgfparserdef{mweparser}{subscript}{\meaning +}{\textbackslash hat\{\pgfparserswitch{edgename}}
\pgfparserdef{mweparser}{subscript}{\meaning -}{\textbackslash check\{\pgfparserswitch{edgename}}
\pgfparserdef{mweparser}{edgename}{\meaning a}{a\}\pgfparserswitch{subscript}}
\pgfparserdef{mweparser}{edgename}{\meaning b}{b\}\pgfparserswitch{subscript}}
\pgfparserdef{mweparser}{subscript}{subscript character _}{\}\pgfparserswitch{initial}}
\pgfparserdef{mweparser}{all}{the character ;}{\pgfparserswitch{final}}
\begin{document}
\pgfparserparse{mweparser}[A_+a-b-a_[A_+a+b-a_]];%
\end{document}
This will output:
\overline{A_{\hat{a}\check{b}\check{a}}\overline{A_{\hat{a}\hat{b}\check{a}}}}
Which is what I would like to run (in math mode). I can store this text in a variable but can't see how I can run it.
I am new to this stuff so I apologise if I have done anything wrong.

\documentclass{...}, the required\usepackage's,\begin{document}, and\end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Mar 25 '14 at 17:55