private static ExpressionNode ParseArrayInitialization(RuleContext rule)
        {
            // An array initialization is the call of a typeNode's constructor

            TypeNode             type            = ParseTreeParser.ParseType((CrawlParser.TypeContext)rule.GetChild(0));
            ArrayConstructorNode typeConstructor = CrawlSyntaxNode.ArrayConstructor(type.Interval, CrawlType.UnspecifiedType, type);
            // TypeConstructorNode is an ExpressionNode that corresponds to a TypeNode

            IEnumerable <ArgumentNode> arguments = ParseCallTail((RuleContext)rule.GetChild(1)).Select(x => CrawlSyntaxNode.Argument(x.Interval, false, x));

            return(CrawlSyntaxNode.Call(rule.SourceInterval, CrawlType.UnspecifiedType, typeConstructor, arguments));
        }
        public static IEnumerable <ArgumentNode> ParseArgumentList(RuleContext argList)
        {
            if (argList.ChildCount == 2)
            {
                yield break;
            }

            argList = (RuleContext)argList.GetChild(1);

            List <ExpressionNode> n = new List <ExpressionNode>(argList.ChildCount / 2);

            for (int i = 0; i < argList.ChildCount; i += 2)
            {
                int  starti    = i;
                bool reference = ((argList.GetChild(i) as ITerminalNode)?.Symbol?.Type == CrawlLexer.REFERENCE);

                if (reference)
                {
                    i++;
                }

                Interval interval = argList.GetChild(starti).SourceInterval;
                interval = interval.Union(argList.GetChild(starti + (reference ? 1 : 0)).SourceInterval);
                yield return(CrawlSyntaxNode.Argument(interval, reference,
                                                      ParseExpression((RuleContext)argList.GetChild(i))));

                if (i + 1 != argList.ChildCount)
                {
                    ITerminalNode itemsep = (ITerminalNode)argList.GetChild(i + 1);
                    if (itemsep.Symbol.Type != CrawlLexer.ITEM_SEPARATOR)
                    {
                        throw new NotImplementedException("Strange stuff in argument list");
                    }
                }
            }

            /*
             * List<ArgumentNode> n = new List<ArgumentNode>();
             * for (int i = 0; i < refExpList.ChildCount; i += 2)
             * {
             *  var refTerminalNode = refExpList.GetChild(i) as ITerminalNode;
             *  if (refTerminalNode == null) // If there is no reference, then the child is an expression
             *  {
             *      n.Add(ParseExpression((RuleContext) refExpList.GetChild(i)));
             *  }
             *  else if (refTerminalNode.Symbol.Type == CrawlLexer.REFERENCE)
             *  {
             *      // If first child is a reference terminal, then the second one is an expression
             *      i = i + 1;
             *      ExpressionNode target = ParseExpression((RuleContext) refExpList.GetChild(i));
             *      n.Add(CrawlSyntaxNode.ReferenceNode(target));
             *  }
             *
             *  if (i != refExpList.ChildCount - 1)
             *  {
             *      // If there are any additional children, then the next one has to be an item separator
             *      ITerminalNode itemsep = (ITerminalNode) refExpList.GetChild(i + 1);
             *      if (itemsep.Symbol.Type != CrawlLexer.ITEM_SEPARATOR) throw new NotImplementedException("Strange stuff in reference expression list");
             *  }
             * }
             * return n; */
        }