After the question Macro for a code translator, I followed the advice of polgab and used the pgf parser module.
I was very disappointed when I reached the point of trying to parse a blank space. I tried different things and at first, I did not find something good. I read the question Parsing text letter by letter and found that was a problem for other people.
I finally found a solution, but don't understand why it works :
\documentclass{minimal}
\usepackage{pgf}
\usepgfmodule{parser}
\pgfparserdef{myparser}{initial}{the letter a}{b}
\futurelet\mystrangemacro{ }
\pgfparserdef{myparser}{initial}{\meaning\mystrangemacro}{a}
\pgfparserdef{myparser}{initial}{alignment tab character &}{\pgfparserswitch{final}}
\begin{document}
\pgfparserparse{myparser}a a aa aa a&
\end{document}
And I get as expected : bababbabbab.
But why is it working ? I tried many different things, and finally tried to use futurelet and it works ! But if I understand the definition of futurelet, my code has no sense..
Thank you for your answers !
\def\:{\let\@sptoken= } \: %" A space is not discarded but is tokenized when following something that got tokenized as a control symbol token, e.g.,\:. Thus this is a nice way of getting two explicit space tokens in a row whereof only the first one is discarded by\let. As\@firstofoneis defined in LaTeX I wonder why not\@firstofone{\let\@sptoken= } %. This way one wouldn't need to define\:. Or, relying on usual lccodes,\lowercase{\let\@sptoken= } %. – Ulrich Diez Aug 01 '21 at 13:01\@firstofone(which was added at 2e) Leslie could have use lowercase as you say, but didn't. – David Carlisle Aug 01 '21 at 17:57