+
+{\catcode`\@=0 \catcode`\\=13
+@catcode`@_=11
+
+% Call #1 with a list of tokens #2, with any doubled backslashes in #2
+% compressed to one.
+@gdef@passargtomacro#1#2{%
+ @def@the_macro{#1}%
+ @def@pending_backslash{}%
+ @def@finish{@finish}%
+ @def@arg_result{}%
+ @let@next_token=@relax
+ @add_segment#2\@finish\%
+}
+
+% Input stream is just after a backslash. If the next token is not a
+% backslash, process the rest of the argument; otherwise, remove the next
+% token.
+@gdef@look_ahead{%
+ @futurelet@next_token@look_aheadzzz}
+@gdef@look_aheadzzz{%
+ @ifx@next_token\%
+ @let@next=@gobble_and_check_finish
+ @else
+ @let@next=@add_segment
+ @fi@next
+}
+
+% Double backslash found. Add a single backslash here.
+@gdef@gobble_and_check_finish#1{%
+ @add_the_backslash
+ @def@pending_backslash{}%
+ @futurelet@next_token@add_segment
+}
+
+% append a backslash to \arg_result
+@gdef@add_the_backslash{%
+ @expandafter@gdef@expandafter@arg_result@expandafter{@arg_result\}%
+}
+
+% Input stream is either at the start of the argument, or just after a
+% backslash sequence, either a lone backslash, or a doubled backslash.
+% \next_token contains the first token in the input stream: if it is \finish,
+% finish; otherwise, append to \arg_result the segment of the argument up until
+% the next backslash. \pending_backslash contains a backslash to represent
+% a backslash just before the start of the input stream that has not been
+% added to \arg_result.
+@gdef@add_segment#1\{%
+@ifx@next_token@finish
+ @let@next=@call_the_macro%
+@else
+ @let@next=@look_ahead
+ %
+ % append to @arg_result
+ % token list registers might be better
+ @expandafter@expandafter@expandafter@gdef
+ @expandafter@expandafter@expandafter@arg_result
+ @expandafter@expandafter@expandafter{%
+ @expandafter@arg_result
+ @pending_backslash#1}%
+ @def@pending_backslash{\}%
+@fi@next}
+
+@gdef@call_the_macro{@expandafter@the_macro@expandafter{@arg_result}}
+
+}
+
+% \braceorline MAC is used for a one-argument macro MAC. It checks
+% whether the next non-whitespace character is a {. It sets the context
+% for reading the argument (slightly different in the two cases). Then,
+% to read the argument, in the whole-line case, it then calls the regular
+% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
+%