Exemplo n.º 1
0
        /*
         *   IdKeyPattern ::= 'id' '(' Literal ')' | 'key' '(' Literal ',' Literal ')'
         */
        private QilNode ParseIdKeyPattern()
        {
            Debug.Assert(_scanner.CanBeFunction);
            Debug.Assert(_scanner.Prefix.Length == 0);
            Debug.Assert(_scanner.Name == "id" || _scanner.Name == "key");
            List <QilNode> args = new List <QilNode>(2);

            if (_scanner.Name == "id")
            {
                _scanner.NextLex();
                _scanner.PassToken(LexKind.LParens);
                _scanner.CheckToken(LexKind.String);
                args.Add(_ptrnBuilder.String(_scanner.StringValue));
                _scanner.NextLex();
                _scanner.PassToken(LexKind.RParens);
                return(_ptrnBuilder.Function("", "id", args));
            }
            else
            {
                _scanner.NextLex();
                _scanner.PassToken(LexKind.LParens);
                _scanner.CheckToken(LexKind.String);
                args.Add(_ptrnBuilder.String(_scanner.StringValue));
                _scanner.NextLex();
                _scanner.PassToken(LexKind.Comma);
                _scanner.CheckToken(LexKind.String);
                args.Add(_ptrnBuilder.String(_scanner.StringValue));
                _scanner.NextLex();
                _scanner.PassToken(LexKind.RParens);
                return(_ptrnBuilder.Function("", "key", args));
            }
        }
Exemplo n.º 2
0
        public QilNode Parse(XPathScanner scanner, IPatternBuilder ptrnBuilder)
        {
            Debug.Assert(_scanner == null && _ptrnBuilder == null);
            Debug.Assert(scanner != null && ptrnBuilder != null);
            QilNode result = null;

            ptrnBuilder.StartBuild();
            try
            {
                _scanner     = scanner;
                _ptrnBuilder = ptrnBuilder;
                result       = this.ParsePattern();
                _scanner.CheckToken(LexKind.Eof);
            }
            finally
            {
                result = ptrnBuilder.EndBuild(result);
#if DEBUG
                this._ptrnBuilder = null;
                this._scanner     = null;
#endif
            }
            return(result);
        }