sed -e 's/\([A-Za-z]*\)\( \)\([A-Za-z]*\)\(:\?\)\([A-Za-z]*\)\?\( \)\?\(.*\)\?/[\1][\2][\3][\4][\5][\6][\7]/'
will decorate
class VoxelbuilderAdda:public VoxelBuilder
So it looks like
[class][ ][VoxelbuilderAdda][:][public][ ][VoxelBuilder]
If I instead have
class VoxelBuilder
The output is
[class][ ][VoxelBuilder][][][][]
Is it possible to stop it from printing the empty brackets?
The goal is to print all identifiers with like (square brackets are my simple placeholders but I should have excluded them for the keywords)
\textclassname{VoxelBuilder}
and leave keywords (class, struct, public, ...) and separators like ':' as is.
Obviously an inverted pattern for keywords+separator is more beneficial, but I could not figure it out. I actually want
Replace sequence X with \textclassname{X} only if X is not one of
class
struct
union
public
private
protected
virtual
:
,
<
>
I have stripped out curly braces and semicolon in an earlier step. The goal would be
class \textclassname{VoxelbuilderAdda}:public \textclassname{VoxelBuilder}
With no inheritance
class \textclassname{VoxelbuilderAdda}
If I had the not operator available, It would not only cover those I have, but any weird multiple inheritance as well.
class, public, …
always begin from start of line or other puctuation symbol like:, >, <, …
? – Costas Aug 12 '15 at 11:42sed 's/ \(\w*\)/ \\textclassname{\1}/g'
– Costas Aug 12 '15 at 11:47struct \textclassname{Twins}:public \textclassname{std}::pair<T,T>
is still wrong. Should have beenstruct \textclassname{Twins}:public \textclassname{std}::\textclassname{pair}<\textclassname{T},\textclassname{T}>
– user877329 Aug 12 '15 at 11:50sed 's/\(::\|[<, ]\)\(\w\+\)/\1\\textclassname{\2}/g'
– Costas Aug 12 '15 at 11:58