public Expression(ExpressionType type)
 {
     this.type           = type;
     this.combinator     = ExpressionCombinator.None;
     this.multiplier     = new ExpressionMultiplier(ExpressionMultiplierType.None);
     this.subExpressions = null;
     this.keyword        = null;
 }
Beispiel #2
0
        private void ParseMultiplier(StyleSyntaxTokenizer tokenizer, ref ExpressionMultiplier multiplier)
        {
            StyleSyntaxToken token = tokenizer.current;

            if (IsMultiplier(token))
            {
                switch (token.type)
                {
                case StyleSyntaxTokenType.Asterisk:
                    multiplier.type = ExpressionMultiplierType.ZeroOrMore;
                    break;

                case StyleSyntaxTokenType.Plus:
                    multiplier.type = ExpressionMultiplierType.OneOrMore;
                    break;

                case StyleSyntaxTokenType.QuestionMark:
                    multiplier.type = ExpressionMultiplierType.ZeroOrOne;
                    break;

                case StyleSyntaxTokenType.HashMark:
                    multiplier.type = ExpressionMultiplierType.OneOrMoreComma;
                    break;

                case StyleSyntaxTokenType.ExclamationPoint:
                    multiplier.type = ExpressionMultiplierType.GroupAtLeastOne;
                    break;

                case StyleSyntaxTokenType.OpenBrace:
                    multiplier.type = ExpressionMultiplierType.Ranges;
                    break;

                default:
                    throw new Exception($"Unexpected token '{token.type}' in expression. Expected multiplier token");
                }

                token = tokenizer.MoveNext();
            }

            if (multiplier.type == ExpressionMultiplierType.Ranges)
            {
                ParseRanges(tokenizer, out multiplier.min, out multiplier.max);
            }
        }
        private void ParseMultiplier(StyleSyntaxTokenizer tokenizer, ref ExpressionMultiplier multiplier)
        {
            StyleSyntaxToken styleSyntaxToken = tokenizer.current;
            bool             flag             = StyleSyntaxParser.IsMultiplier(styleSyntaxToken);

            if (flag)
            {
                switch (styleSyntaxToken.type)
                {
                case StyleSyntaxTokenType.Asterisk:
                    multiplier.type = ExpressionMultiplierType.ZeroOrMore;
                    goto IL_A1;

                case StyleSyntaxTokenType.Plus:
                    multiplier.type = ExpressionMultiplierType.OneOrMore;
                    goto IL_A1;

                case StyleSyntaxTokenType.QuestionMark:
                    multiplier.type = ExpressionMultiplierType.ZeroOrOne;
                    goto IL_A1;

                case StyleSyntaxTokenType.HashMark:
                    multiplier.type = ExpressionMultiplierType.OneOrMoreComma;
                    goto IL_A1;

                case StyleSyntaxTokenType.ExclamationPoint:
                    multiplier.type = ExpressionMultiplierType.GroupAtLeastOne;
                    goto IL_A1;

                case StyleSyntaxTokenType.OpenBrace:
                    multiplier.type = ExpressionMultiplierType.Ranges;
                    goto IL_A1;
                }
                throw new Exception(string.Format("Unexpected token '{0}' in expression. Expected multiplier token", styleSyntaxToken.type));
IL_A1:
                styleSyntaxToken = tokenizer.MoveNext();
            }
            bool flag2 = multiplier.type == ExpressionMultiplierType.Ranges;

            if (flag2)
            {
                this.ParseRanges(tokenizer, out multiplier.min, out multiplier.max);
            }
        }