I have been working on writing a recursive stream processor in latex that converts a shorthand version of a set of highly used commands into a much longer form. The code below represents what I had done so far before realizing that xstrings cannot allow you to nest macros.
The program is supposed to do the following:
- Checks to see if the input is 0 length.
- otherwise it checks to see if there are any commands in the first set (right now there is just rotate)
- otherwise it checks to see if there are any commands in the second set (where flip is)
- otherwise it just returns the symbol
if it finds a symbol it nests and recursively calls with the remaining characters in the input stream, otherwise it just appends the recursive call to the current character.
I want to keep the recursive nature of the program because that makes the most logical sense because there is the possibility of things being nested
\newcommand{\processSymbol}[1]{
\IfEq{0}{\StrLen{#1}}{}{\CheckRotate{\firstChar{#1}}{\restChars{#1}}}
}
\newcommand{\AECheckRotate}[2]{
\begin{switch}{#1}
\case{c}{\AEccwRotate{\processSymbol{#2}}}
\AECheckFlip{#1}{#2}
\end{switch}
}
\newcommand{\AECheckFlip}[2]{
\begin{switch}
\case{v}{\flipv{\processSymbol{#2}}}
#1\processSymbol{#2}
\end{switch}
}
although the command set is arbitrary, a sample input for the sample code that I wrote would be something like:
vccb
which should in my full code return something that will look like:
P
because it would rotate, rotate and vertically flip the letter b.
I'm trying to figure out another way to do nested string parsing in this way. and I have a feeling that it can't be done with xstrings. If I need to switch to using LuaTex then so be it. just trying to do this in LaTeX before I need to learn Lua
\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That is much more useful than a fragment as it can be copy-pasted and (try-to) compile to reproduce the issue.