Ejemplo n.º 1
0
        internal static string MatchType(
            string input,
            ref int offset,
            Tokenizer tokenizer,
            bool commaTerminates)
        {
            int           num           = 1;
            bool          flag          = false;
            StringBuilder stringBuilder = new StringBuilder();

            while (offset < input.Length)
            {
                char ch = input[offset++];
                if (ch == '\n' || ch == '\r')
                {
                    --offset;
                    break;
                }
                if (ch == ']')
                {
                    --num;
                    if (num == 0)
                    {
                        flag = true;
                        break;
                    }
                }
                else if (ch == ',' && commaTerminates && num == 1)
                {
                    flag = true;
                    break;
                }
                if (ch == '[')
                {
                    ++num;
                }
                if (ch == '`')
                {
                    if (offset < input.Length)
                    {
                        stringBuilder.Append(StringTokenReader.Backtick(input[offset++]));
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    stringBuilder.Append(ch);
                }
            }
            if (flag)
            {
                return(stringBuilder.ToString() ?? "");
            }
            tokenizer?.Parser.ReportException((object)stringBuilder.ToString(), typeof(IncompleteParseException), tokenizer.PositionToken(offset), "EndSquareBracketExpectedAtEndOfType");
            return((string)null);
        }
Ejemplo n.º 2
0
        private string MatchAttribute(string input, ref int offset)
        {
            int           num           = 1;
            StringBuilder stringBuilder = new StringBuilder();

            while (offset < input.Length)
            {
                char ch = input[offset++];
                if (ch == '\n' || ch == '\r')
                {
                    --offset;
                    break;
                }
                if ((ch == ']' || ch == '(') && num == 1)
                {
                    --offset;
                    return(stringBuilder.ToString() ?? "");
                }
                if (ch == ']')
                {
                    --num;
                }
                if (ch == '[')
                {
                    ++num;
                }
                if (ch == '`')
                {
                    if (offset < input.Length)
                    {
                        stringBuilder.Append(StringTokenReader.Backtick(input[offset++]));
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    stringBuilder.Append(ch);
                }
            }
            this.Tokenizer.Parser.ReportException((object)stringBuilder.ToString(), typeof(IncompleteParseException), this.Tokenizer.PositionToken(offset), "EndSquareBracketExpectedAtEndOfAttribute");
            return((string)null);
        }