/// <summary>
        /// Visits the syntax node.
        /// </summary>
        /// <param name="type">Type</param>
        public void Visit(ref PMapType type)
        {
            type.TypeTokens.Add(base.TokenStream.Peek());

            base.TokenStream.Index++;
            base.TokenStream.SkipWhiteSpaceAndCommentTokens();

            if (base.TokenStream.Done ||
                base.TokenStream.Peek().Type != TokenType.LeftSquareBracket)
            {
                throw new ParsingException("Expected \"[\".",
                    new List<TokenType>
                {
                    TokenType.LeftSquareBracket
                });
            }

            type.TypeTokens.Add(base.TokenStream.Peek());

            base.TokenStream.Index++;
            base.TokenStream.SkipWhiteSpaceAndCommentTokens();

            if (base.TokenStream.Done ||
                (base.TokenStream.Peek().Type != TokenType.MachineDecl &&
                base.TokenStream.Peek().Type != TokenType.Int &&
                base.TokenStream.Peek().Type != TokenType.Bool &&
                base.TokenStream.Peek().Type != TokenType.Seq &&
                base.TokenStream.Peek().Type != TokenType.Map &&
                base.TokenStream.Peek().Type != TokenType.Any &&
                base.TokenStream.Peek().Type != TokenType.EventDecl &&
                base.TokenStream.Peek().Type != TokenType.LeftParenthesis))
            {
                throw new ParsingException("Expected \"[\".",
                    new List<TokenType>
                {
                    TokenType.MachineDecl,
                    TokenType.Int,
                    TokenType.Bool,
                    TokenType.Seq,
                    TokenType.Map,
                    TokenType.Any,
                    TokenType.EventDecl
                });
            }

            PBaseType keyType = null;
            new TypeIdentifierVisitor(base.TokenStream).Visit(ref keyType);
            type.KeyType = keyType;

            if (base.TokenStream.Done ||
                base.TokenStream.Peek().Type != TokenType.Comma)
            {
                throw new ParsingException("Expected \",\".",
                    new List<TokenType>
                {
                    TokenType.Comma
                });
            }

            base.TokenStream.Index++;
            base.TokenStream.SkipWhiteSpaceAndCommentTokens();

            if (base.TokenStream.Done ||
                (base.TokenStream.Peek().Type != TokenType.MachineDecl &&
                base.TokenStream.Peek().Type != TokenType.Int &&
                base.TokenStream.Peek().Type != TokenType.Bool &&
                base.TokenStream.Peek().Type != TokenType.Seq &&
                base.TokenStream.Peek().Type != TokenType.Map &&
                base.TokenStream.Peek().Type != TokenType.Any &&
                base.TokenStream.Peek().Type != TokenType.EventDecl &&
                base.TokenStream.Peek().Type != TokenType.LeftParenthesis))
            {
                throw new ParsingException("Expected \"[\".",
                    new List<TokenType>
                {
                    TokenType.MachineDecl,
                    TokenType.Int,
                    TokenType.Bool,
                    TokenType.Seq,
                    TokenType.Map,
                    TokenType.Any,
                    TokenType.EventDecl
                });
            }

            PBaseType valueType = null;
            new TypeIdentifierVisitor(base.TokenStream).Visit(ref valueType);
            type.ValueType = valueType;

            if (base.TokenStream.Done ||
                base.TokenStream.Peek().Type != TokenType.RightSquareBracket)
            {
                throw new ParsingException("Expected \"]\".",
                    new List<TokenType>
                {
                    TokenType.RightSquareBracket
                });
            }

            type.TypeTokens.Add(base.TokenStream.Peek());
        }
        /// <summary>
        /// Visits the type.
        /// </summary>
        /// <param name="type">Type</param>
        public void Visit(ref PBaseType type)
        {
            if (base.TokenStream.Done ||
                    (base.TokenStream.Peek().Type != TokenType.MachineDecl &&
                    base.TokenStream.Peek().Type != TokenType.Int &&
                    base.TokenStream.Peek().Type != TokenType.Bool &&
                    base.TokenStream.Peek().Type != TokenType.Seq &&
                    base.TokenStream.Peek().Type != TokenType.Map &&
                    base.TokenStream.Peek().Type != TokenType.Any &&
                    base.TokenStream.Peek().Type != TokenType.EventDecl &&
                    base.TokenStream.Peek().Type != TokenType.LeftParenthesis))
            {
                throw new ParsingException("Expected type.",
                    new List<TokenType>
                {
                    TokenType.MachineDecl,
                    TokenType.Int,
                    TokenType.Bool,
                    TokenType.Seq,
                    TokenType.Map,
                    TokenType.Any,
                    TokenType.EventDecl
                });
            }

            if (base.TokenStream.Peek().Type == TokenType.MachineDecl)
            {
                base.TokenStream.Swap(new Token(new TextUnit("MachineId", base.TokenStream.
                    Peek().TextUnit.Line), TokenType.MachineDecl));
                type = new PBaseType(PType.Machine);
                type.TypeTokens.Add(base.TokenStream.Peek());
            }
            else if (base.TokenStream.Peek().Type == TokenType.Int)
            {
                type = new PBaseType(PType.Int);
                type.TypeTokens.Add(base.TokenStream.Peek());
            }
            else if (base.TokenStream.Peek().Type == TokenType.Bool)
            {
                type = new PBaseType(PType.Bool);
                type.TypeTokens.Add(base.TokenStream.Peek());
            }
            else if (base.TokenStream.Peek().Type == TokenType.Any)
            {
                type = new PBaseType(PType.Any);
                type.TypeTokens.Add(base.TokenStream.Peek());
            }
            else if (base.TokenStream.Peek().Type == TokenType.EventDecl)
            {
                type = new PBaseType(PType.Event);
                type.TypeTokens.Add(base.TokenStream.Peek());
            }
            else if (base.TokenStream.Peek().Type == TokenType.Seq)
            {
                var seqType = new PSeqType();
                new SeqTypeIdentifierVisitor(base.TokenStream).Visit(ref seqType);
                type = seqType;
            }
            else if (base.TokenStream.Peek().Type == TokenType.Map)
            {
                var mapType = new PMapType();
                new MapTypeIdentifierVisitor(base.TokenStream).Visit(ref mapType);
                type = mapType;
            }
            else if (base.TokenStream.Peek().Type == TokenType.LeftParenthesis)
            {
                var tupleType = new PTupleType();
                new TupleTypeIdentifierVisitor(base.TokenStream).Visit(ref tupleType);
                type = tupleType;
            }

            base.TokenStream.Index++;
            base.TokenStream.SkipWhiteSpaceAndCommentTokens();
        }