Example #1
0
        public override void ExitExpressionList(GoParser.ExpressionListContext context)
        {
            List <ExpressionInfo> expressions = new List <ExpressionInfo>();

            for (int i = 0; i < context.expression().Length; i++)
            {
                if (Expressions.TryGetValue(context.expression(i), out ExpressionInfo expression))
                {
                    expressions.Add(expression);
                }
            }

            ExpressionLists[context] = expressions.ToArray();
        }
Example #2
0
        public override void ExitExprCaseClause(GoParser.ExprCaseClauseContext context)
        {
            // exprSwitchStmt
            //     : 'switch'(simpleStmt ';') ? expression ? '{' exprCaseClause * '}'

            // exprCaseClause
            //     : exprSwitchCase ':' statementList

            // exprSwitchCase
            //     : 'case' expressionList | 'default'

            IndentLevel--;

            ExprSwitchStatement exprSwitchStatement = m_exprSwitchStatements.Peek();

            GoParser.ExpressionListContext expressionList = context.exprSwitchCase().expressionList();

            if (expressionList is null)
            {
                exprSwitchStatement.defaultCase.block = PopBlock(false);
            }
            else
            {
                if (!ExpressionLists.TryGetValue(expressionList, out ExpressionInfo[] expressions))