Mostly for fun, I'm trying to make % comments manipulatable using the \lowercase trick. For some reason, I'm getting a strange (to me) error:
ERROR: LaTeX Error: Missing \begin{document}.
--- TeX said ---
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.22 \VisibleComments
Generally when I get this kind of error, I have unbalanced brace groups somewhere. As far as I can tell, this is not the case here.
MWE
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\cs_new_protected:Nn \vc_make_comment:n
{ \textbf{Comment: `#1'} }
\cs_new:Nn \vc_visible_comments:
{
\group_begin:
\char_set_lccode:nn {`\~} {`\%}
\tl_to_lowercase:n
{ \group_end: \cs_set_eq:NN ~ } \vc_make_comment:n
\char_set_catcode_active:N \%
}
\NewDocumentCommand \VisibleComments { }
{ \vc_visible_comments: }
\ExplSyntaxOff
\VisibleComments
\begin{document}
Hello, this is a % comment
\end{document}
Expecting: Hello, this is a \textbf{Comment: `comment'}

\vc_make_comment:wto scan until the end of the line and feed that into\vc_make_comment:nfor 'proper' behavior.) – Sean Allred Sep 07 '15 at 16:51