示例#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);
        }
        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);
        }
示例#3
0
 public ExpandableStringNode(Token token, Parser parser)
 {
     this.NodeToken         = token;
     this._formatExpression = StringTokenReader.ExpandStringToFormatExpression((IStringTokenReaderHelper2) new StringTokenReaderParseTimeHelper(parser, this.NodeToken.StartLineNumber), this.NodeToken, token.TokenText);
 }
示例#4
0
 internal string Expand(string s) => (string)this.Execute(StringTokenReader.ExpandStringToFormatExpression((IStringTokenReaderHelper2) new StringTokenReaderRunTimeHelper(this.EngineParser), (Token)null, s), (Array)null);