Skip to content

Commit

Permalink
ENH Implement \string (except for escapechar)
Browse files Browse the repository at this point in the history
  • Loading branch information
luispedro committed Jul 24, 2012
1 parent 1b571fc commit 5070eac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hex/Macros.lhs
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions hex/tests/expanded/string.hex
@@ -0,0 +1 @@
\string\test%
1 change: 1 addition & 0 deletions hex/tests/expanded/string.output
@@ -0,0 +1 @@
<\(12)><t(12)><e(12)><s(12)><t(12)>

0 comments on commit 5070eac

Please sign in to comment.