Пример #1
0
        private bool ParseStatement(TemplateStream stream, TokenList tokens, ContextStack context, ScopeStack scope)
        {
            if (scope.Current == Scope.Statement)
            {
                scope.Pop();
            }
            else if (scope.Current == Scope.Block)
            {
                var previous = stream.Peek(-1);
                if (previous == '$' || char.IsLetterOrDigit(previous)) return false;
            }
            else
            {
                return false;
            }

            var name = stream.PeekWord();
            var identifier = context.Current.GetIdentifier(name);

            if (identifier != null)
            {
                tokens.Add(new Token(stream.Position, name.Length, stream.Line, TokenType.Identifier, context.Current, identifier.QuickInfo));
                stream.Advance(name.Length);

                if (identifier.Type == IdentifierType.Indexed)
                {
                    if (stream.Current == '(') scope.Push(Scope.Filter);
                    if (stream.Current == '[')
                    {
                        scope.Push(Scope.Template);
                        context.Push(name, stream.Position);
                    }
                }
                else if (identifier.Type == IdentifierType.Boolean)
                {
                    if (stream.Current == '[') scope.Push(Scope.True);
                }

                return true;
            }

            return false;
        }