示例#1
0
        public override BaseState Eval(string c)
        {
            switch (c)
            {
            case "{":
                var selectorToken = Scope.CurrentToken.Flush().Trim();
                if (Scope.Command == "plural")
                {
                    ValidateSelector(selectorToken);
                }

                // Start new child scope with state set to TextAppenderState
                var branchScope = Scope.AddBranchScope(selectorToken);
                branchScope.IsPluralBranch = true;
                branchScope.Offset         = _offset;
                return(branchScope.State);

            case "}":
                // End of conditional
                // Get rid of any potential white space characters
                Scope.CurrentToken.Flush();

                // Evaluate which one of the branches we should use
                Scope.AddBranchResult();

                // Go back to basic the text parsing state
                return(TransitionTo <TextAppenderState>());
            }

            if (Regex.IsMatch(Scope.CurrentToken + c, "\\s*offset\\s*:"))
            {
                Scope.CurrentToken.Clear();
                return(TransitionTo <OffsetState>());
            }
            Scope.CurrentToken.Append(c);
            return(this);
        }