diff --git a/hex/Macros.lhs b/hex/Macros.lhs index 8a8c65f..90ce42f 100644 --- a/hex/Macros.lhs +++ b/hex/Macros.lhs @@ -800,6 +800,17 @@ process1 (ControlSequence "\\expandafter") = do puttokenM unexp \end{code} +\begin{code} +process1 (ControlSequence "\\string") = do + unexp <- gettokenM + case unexp of + CharToken _ -> puttokenM unexp + ControlSequence csname -> mapM_ putC (reverse csname) + where + putC ' ' = puttokenM (CharToken (TypedChar ' ' Space)) + putC c = puttokenM (CharToken (TypedChar c Other)) +\end{code} + Manipulation of catcodes is performed here. It needs to change the token stream. In hex, the ``environment'' is actually a few separate namespaces, \tex{\\catcode} only manipulates the category table embedded in the tokens diff --git a/hex/tests/expanded/string.hex b/hex/tests/expanded/string.hex new file mode 100644 index 0000000..aad4608 --- /dev/null +++ b/hex/tests/expanded/string.hex @@ -0,0 +1 @@ +\string\test% diff --git a/hex/tests/expanded/string.output b/hex/tests/expanded/string.output new file mode 100644 index 0000000..e3909fc --- /dev/null +++ b/hex/tests/expanded/string.output @@ -0,0 +1 @@ +<\(12)>