Ejemplo n.º 1
0
        public void CaseClosure()
        {
            int num5 = base.Edges().Count() - 1;

            for (int i = 0; i <= num5; i++)
            {
                NumberSet    setB       = new NumberSet(new int[0]);
                CharacterSet characters = base.Edges()[i].Characters;
                int          num6       = characters.Count() - 1;
                for (int j = 0; j <= num6; j++)
                {
                    int charCode = characters[j];
                    int num3     = UnicodeTable.ToLowerCase(charCode);
                    if (charCode != num3)
                    {
                        setB.Add(new int[] { num3 });
                    }
                    num3 = UnicodeTable.ToUpperCase(charCode);
                    if (charCode != num3)
                    {
                        setB.Add(new int[] { num3 });
                    }
                }
                characters.UnionWith(setB);
                characters = null;
            }
        }
Ejemplo n.º 2
0
        public void MappingClosure(BuilderApp.CharMappingMode Mapping)
        {
            int num5 = base.Edges().Count() - 1;

            for (int i = 0; i <= num5; i++)
            {
                NumberSet    setB       = new NumberSet(new int[0]);
                CharacterSet characters = base.Edges()[i].Characters;
                int          num6       = characters.Count() - 1;
                for (int j = 0; j <= num6; j++)
                {
                    int charCode = characters[j];
                    int num3     = UnicodeTable.ToWin1252(charCode);
                    if (charCode != num3)
                    {
                        setB.Add(new int[] { num3 });
                    }
                }
                characters.UnionWith(setB);
                characters = null;
            }
        }
Ejemplo n.º 3
0
        public string ParseUntil(ParseRule stopRule, CharacterSet pauseCharacters = null, CharacterSet endCharacters = null)
        {
            int ruleId = BeginRule();


            CharacterSet pauseAndEnd = new CharacterSet();

            if (pauseCharacters != null)
            {
                pauseAndEnd.UnionWith(pauseCharacters);
            }
            if (endCharacters != null)
            {
                pauseAndEnd.UnionWith(endCharacters);
            }

            StringBuilder parsedString      = new StringBuilder();
            object        ruleResultAtPause = null;

            // Keep attempting to parse strings up to the pause (and end) points.
            //  - At each of the pause points, attempt to parse according to the rule
            //  - When the end point is reached (or EOF), we're done
            do
            {
                // TODO: Perhaps if no pause or end characters are passed, we should check *every* character for stopRule?
                string partialParsedString = ParseUntilCharactersFromCharSet(pauseAndEnd);
                if (partialParsedString != null)
                {
                    parsedString.Append(partialParsedString);
                }

                // Attempt to run the parse rule at this pause point
                ruleResultAtPause = Peek(stopRule);

                // Rule completed - we're done
                if (ruleResultAtPause != null)
                {
                    break;
                }
                else
                {
                    if (endOfInput)
                    {
                        break;
                    }

                    // Reached a pause point, but rule failed. Step past and continue parsing string
                    char pauseCharacter = currentCharacter;
                    if (pauseCharacters != null && pauseCharacters.Contains(pauseCharacter))
                    {
                        parsedString.Append(pauseCharacter);
                        if (pauseCharacter == '\n')
                        {
                            lineIndex++;
                        }
                        index++;
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
            } while(true);

            if (parsedString.Length > 0)
            {
                return((string)SucceedRule(ruleId, parsedString.ToString()));
            }
            else
            {
                return((string)FailRule(ruleId));
            }
        }