示例#1
0
        protected void SkipToTableAndParseIt(Action <IList <string> > processTableRowDelegate)
        {
            while (true)
            {
                WikiContentType contentType = wikiParser.Next();
                if (contentType == WikiContentType.Table)
                {
                    wikiParser.ParseTable(processTableRowDelegate);
                    return;
                }

                if (contentType == WikiContentType.Text)
                {
                    continue;
                }

                ThrowParseError("Wiki table expected");
            }
        }
示例#2
0
        private void ParsePointPattern(string patternName)
        {
            currentParsedPattern = new PatternDefinition(patternName);

            SkipToTableAndParseIt(ParseColorTable);

            // collect all pattern lines
            StringBuilder patternText = new StringBuilder();

            while (true)
            {
                WikiContentType wikiContentType = WikiParser.Next();

                if (wikiContentType != WikiContentType.Text)
                {
                    break;
                }

                patternText.Append(WikiParser.Context.CurrentLine);
            }

            MatchCollection matches = regexPointPattern.Matches(patternText.ToString());

            if (matches.Count < 1)
            {
                ThrowParseError("Invalid point pattern: '{0}'", patternText.ToString());
            }

            Match match = matches[0];
            Group group = match.Groups["line"];

            foreach (Capture capture in group.Captures)
            {
                string patternLine = capture.Value;

                if (patternLine != null)
                {
                    // all pattern lines have to be of the same length
                    if (currentParsedPattern.Width != -1)
                    {
                        if (patternLine.Length != currentParsedPattern.Width)
                        {
                            ThrowParseError("All pattern lines have to be of the same width.");
                        }
                    }

                    currentParsedPattern.PatternLines.Add(patternLine);

                    if (currentParsedPattern.Width > 24)
                    {
                        ThrowParseError("Point pattern can have a maximum width of 24 characters");
                    }
                }
            }

            if (currentParsedPattern.Height > 24)
            {
                ThrowParseError("Point pattern can have a maximum height of 24 characters");
            }

            this.typesRegistry.Patterns.Add(currentParsedPattern.PatternName, currentParsedPattern);
        }
示例#3
0
 public WikiContentType RegisterContentType(WikiContentType contentType)
 {
     this.currentType = contentType;
     return(contentType);
 }