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); }
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; } } }
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); } } }
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); } }
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; } } }
public object VisitJPath(XjPath node) { throw new NotImplementedException(); }