def checkMessageExpressions(val, message):
    if isinstance(message, ModelMessage) and not hasattr(message,"expressions"):
        formatString = []
        expressions = []
        bracketNesting = 0
        skipTo = None
        expressionIndex = 0
        expression = None
        lastC = None
        for c in message.text:
            if skipTo:
                if c == skipTo:
                    skipTo = None
            if expression is not None and c in ('\'', '"'):
                skipTo = c
            elif lastC == c and c in ('{','}'):
                lastC = None
            elif lastC == '{': 
                bracketNesting += 1
                expression = []
                lastC = None
            elif c == '}' and expression is not None: 
                expressions.append( ''.join(expression).strip() )
                expression = None
                formatString.append( "0[{0}]".format(expressionIndex) )
                expressionIndex += 1
                lastC = c
            elif lastC == '}':
                bracketNesting -= 1
                lastC = None
            else:
                lastC = c
                
            if expression is not None: expression.append(c)
            else: formatString.append(c)
            
        if lastC == '}':
            bracketNesting -= 1
        if bracketNesting:
            val.modelXbrl.error("xbrlmsge:missingLeftCurlyBracketInMessage" if bracketNesting < 0 else "xbrlmsge:missingRightCurlyBracketInMessage",
                _("Message %(xlinkLabel)s: unbalanced %(character)s character(s) in: %(text)s"),
                modelObject=message, xlinkLabel=message.xlinkLabel, 
                character='{' if bracketNesting < 0 else '}', 
                text=message.text,
                messageCodes=("xbrlmsge:missingLeftCurlyBracketInMessage", "xbrlmsge:missingRightCurlyBracketInMessage"))
        else:
            message.expressions = expressions
            message.formatString = ''.join( formatString )
        if not message.xmlLang:
            val.modelXbrl.error("xbrlmsge:xbrlmsge:missingMessageLanguage",
                _("Message %(xlinkLabel)s is missing an effective value for xml:lang: %(text)s."),
                modelObject=message, xlinkLabel=message.xlinkLabel, text=message.text)
dataset/ETHPy150Open Arelle/Arelle/arelle/ValidateFormula.py/checkMessageExpressions/original