Пример #1
0
        private Mapping ParseBlockMapping(out bool success)
        {
            int errorCount = Errors.Count;
            Mapping mapping = new Mapping();

            while (true)
            {
                int seq_start_position1 = position;
                MappingEntry mappingEntry = ParseBlockMappingEntry(out success);
                if (success) { mapping.Enties.Add(mappingEntry); }
                else
                {
                    Error("Failed to parse BlockMappingEntry of BlockMapping.");
                    break;
                }

                while (true)
                {
                    while (true)
                    {
                        int seq_start_position2 = position;
                        ParseIndent(out success);
                        if (!success)
                        {
                            Error("Failed to parse Indent of BlockMapping.");
                            break;
                        }

                        mappingEntry = ParseBlockMappingEntry(out success);
                        if (success) { mapping.Enties.Add(mappingEntry); }
                        else
                        {
                            Error("Failed to parse BlockMappingEntry of BlockMapping.");
                            position = seq_start_position2;
                        }
                        break;
                    }
                    if (!success) { break; }
                }
                success = true;
                break;
            }
            if (success) { ClearError(errorCount); }
            else { Error("Failed to parse Enties of BlockMapping."); }
            return mapping;
        }
Пример #2
0
        private Mapping ParseFlowMapping(out bool success)
        {
            int errorCount = Errors.Count;
            Mapping mapping = new Mapping();
            int start_position = position;

            MatchTerminal('{', out success);
            if (!success)
            {
                Error("Failed to parse '{' of FlowMapping.");
                position = start_position;
                return mapping;
            }

            ParseSeparationLinesInFlow(out success);
            success = true;

            while (true)
            {
                int seq_start_position1 = position;
                MappingEntry mappingEntry = ParseFlowMappingEntry(out success);
                if (success) { mapping.Enties.Add(mappingEntry); }
                else
                {
                    Error("Failed to parse FlowMappingEntry of FlowMapping.");
                    break;
                }

                while (true)
                {
                    while (true)
                    {
                        int seq_start_position2 = position;
                        MatchTerminal(',', out success);
                        if (!success)
                        {
                            Error("Failed to parse ',' of FlowMapping.");
                            break;
                        }

                        ParseSeparationLinesInFlow(out success);
                        success = true;

                        mappingEntry = ParseFlowMappingEntry(out success);
                        if (success) { mapping.Enties.Add(mappingEntry); }
                        else
                        {
                            Error("Failed to parse FlowMappingEntry of FlowMapping.");
                            position = seq_start_position2;
                        }
                        break;
                    }
                    if (!success) { break; }
                }
                success = true;
                break;
            }
            if (!success)
            {
                Error("Failed to parse Enties of FlowMapping.");
                position = start_position;
                return mapping;
            }

            MatchTerminal('}', out success);
            if (!success)
            {
                Error("Failed to parse '}' of FlowMapping.");
                position = start_position;
            }

            if (success) { ClearError(errorCount); }
            return mapping;
        }