msgNameStack = []

def pushMsgName(str, loc, tokens):
    msgNameStack.append(tokens[0])
tokens[0] = '.'.join(msgNameStack)

def popMsgName(str, loc, tokens):
    msgNameStack.pop()
closeBrace = pp.Suppress(pp.Literal('}')).setParseAction(popMsgName)
messageName = ident.setParseAction(pushMsgName)
preserving text structure information - pyparsing