Пример #1
0
        private ParserInfo GetParserInfo(Type dataType)
        {
            if (!parserInfoList.TryGetValue(dataType, out ParserInfo info))
            {
                info = new ParserInfo(dataType);
                parserInfoList.Add(dataType, info);
            }

            return(info);
        }
Пример #2
0
        private void ParseGlobal_Expr_List(UDMFParsedMapData dataClass, ParserInfo info)
        {
            unknownGlobalAssignmentsPooled.Clear();
            unknownBlocksPooled.Clear();

            UDMFToken tok = scanner.LookAhead();

            while (tok.Type == UDMFTokenType.IDENTIFIER)
            {
                ParseGlobal_Expr(dataClass, info);

                tok = scanner.LookAhead();
            }

            if (unknownGlobalAssignmentsPooled.Count > 0)
            {
                dataClass.UnknownGlobalAssignments = new Dictionary <string, UDMFUnknownAssignment> (
                    unknownGlobalAssignmentsPooled,
                    StringComparer.InvariantCultureIgnoreCase
                    );

                unknownGlobalAssignmentsPooled.Clear();
            }

            if (unknownBlocksPooled.Count > 0)
            {
                dataClass.UnknownBlocks = new Dictionary <string, List <UDMFUnknownBlock> > (unknownBlocksPooled.Count);
                foreach (var kvp in unknownBlocksPooled)
                {
                    var pooledList = kvp.Value;
                    var newList    = new List <UDMFUnknownBlock> (pooledList.Count);

                    foreach (var block in pooledList)
                    {
                        newList.Add(block);
                    }

                    dataClass.UnknownBlocks.Add(kvp.Key, newList);

                    pooledList.Clear();
                    pooledList.Capacity = 0;
                }

                unknownBlocksPooled.Clear();
            }
        }
Пример #3
0
        private void ParseGlobal_Expr(UDMFParsedMapData dataClass, ParserInfo info)
        {
            UDMFToken tok = scanner.Scan();

            if (tok.Type != UDMFTokenType.IDENTIFIER)
            {
                Errors.Add(new UDMFParseError("Unexpected token '" + tok.Text.ToString().Replace("\n", "") + "' found. Expected " + UDMFToken.TokenTypeToString(UDMFTokenType.IDENTIFIER), 0x1001, tok));
                return;
            }

            var ident     = tok;
            var identText = namePool.GetOrCreate(ident.Text);

            tok = scanner.LookAhead();
            switch (tok.Type)
            {
            case UDMFTokenType.BROPEN:
                ParserInfo.BlockInfo block;
                info.Blocks.TryGetValue(identText, out block);
                ParseBlock(dataClass, identText, block);
                break;

            case UDMFTokenType.EQSIGN:
                if (info.GlobalAssignments.TryGetValue(identText, out var assignment))
                {
                    ParseAssignment_Expr(dataClass, assignment);
                }
                else
                {
                    var val = ParseAssignment_Expr(dataClass, null);
                    unknownGlobalAssignmentsPooled.Add(identText, GetUnknownAssignment(val.Value));
                }
                break;

            default:
                Errors.Add(new UDMFParseError("Unexpected token '" + tok.Text.ToString().Replace("\n", "") + "' found.", 0x0002, tok));
                return;
            }

            return;
        }