Exemplo n.º 1
0
        private XjPath ParseRoot(Queue <Token> tokens)
        {
            XjPath prop = null;

            while (tokens.Count > 0)
            {
                var token = tokens.Dequeue();
                switch (token.Kind)
                {
                case KindToken.Identifier:
                    if (prop != null)
                    {
                        throw new ParsingException(token.Text, token.Index);
                    }
                    prop = new XjPath()
                    {
                        Type = token.Text.ToLower()
                    };
                    break;

                case KindToken.Left:
                    if (prop == null)
                    {
                        throw new ParsingException(token.Text, token.Index);
                    }
                    if (prop.Type == "jpath")
                    {
                        ParseJpath(tokens, prop);
                    }
                    else
                    {
                        ParseFunction(tokens, prop);
                    }
                    break;

                case KindToken.Pipe:
                    ParseFunction(tokens, prop);
                    break;

                case KindToken.Right:
                    break;

                default:
                    break;
                }
            }

            return(prop);
        }
Exemplo n.º 2
0
        private void ParseProperty(Queue <Token> tokens, XjsltProperty prop)
        {
            XjPath p = null;

            while (tokens.Count > 0)
            {
                var token = tokens.Dequeue();
                switch (token.Kind)
                {
                case KindToken.Identifier:
                    p = new XjPath()
                    {
                        Type = token.Text.ToLower()
                    };
                    prop.Value = p;
                    break;

                case KindToken.Left:
                    if (p == null)
                    {
                        throw new ParsingException(token.Text, token.Index);
                    }
                    if (p.Type == "jpath")
                    {
                        ParseJpath(tokens, p);
                    }
                    else
                    {
                        ParseFunction(tokens, p);
                    }
                    break;

                case KindToken.Pipe:
                    ParseFunction(tokens, p);
                    break;

                case KindToken.Right:
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void ParseJpath(Queue <Token> tokens, XjPath prop)
        {
            while (tokens.Count > 0)
            {
                var token = tokens.Dequeue();
                switch (token.Kind)
                {
                case KindToken.Identifier:
                    prop.Value = token.Text;
                    break;

                case KindToken.Right:
                    return;

                default:
                    throw new ParsingException(token.Text, token.Index);
                }
            }
        }
Exemplo n.º 4
0
        public object VisitJPath(XjPath node)
        {
            using (var ctx = NewContext())
            {
                if (node.Type == "jpath")
                {
                    ctx.Current.RootSource = Expression.Call(RuntimeContext._getContentByJPath.Method, ctx.Current.Context, ctx.Current.RootSource, Expression.Constant(node.Value));
                }

                else
                {
                }

                if (node.Child != null)
                {
                    ctx.Current.RootSource = (Expression)node.Child.Accept(this);
                }

                return(ctx.Current.RootSource);
            }
        }
Exemplo n.º 5
0
        private void ParseFunction(Queue <Token> tokens, XjPath propRoot)
        {
            XjsltObject o    = null;
            string      type = string.Empty;

            while (tokens.Count > 0)
            {
                var token = tokens.Dequeue();
                switch (token.Kind)
                {
                case KindToken.Identifier:
                    type = token.Text;
                    o    = new XjsltObject()
                    {
                    };
                    break;

                case KindToken.Left:
                    if (o == null)
                    {
                        throw new ParsingException(token.Text, token.Index);
                    }
                    ParseObject(tokens, o);
                    propRoot.Child = new XjsltType(o)
                    {
                        Type = type
                    };
                    break;

                case KindToken.Pipe:
                    throw new ParsingException(token.Text, token.Index);

                case KindToken.Right:
                    return;

                default:
                    break;
                }
            }
        }
Exemplo n.º 6
0
 public object VisitJPath(XjPath node)
 {
     throw new NotImplementedException();
 }