public static object parse(Expr rootParser, XPathLexer lexer) { Dictionary<string, object> absoluteLocation = new Dictionary<string, object>(); absoluteLocation.Add("type", XPathAnalyzer.ExprType.ABSOLUTE_LOCATION_PATH); while (!lexer.empty() && (lexer.peak()[0] == '/')) { if(!absoluteLocation.ContainsKey("steps")) absoluteLocation.Add("steps", new List<Dictionary<string, object>>()); if (lexer.next().Equals("/")) { var next = lexer.peak(); if (!lexer.empty() && (next.Equals(".") || next.Equals("..") || next.Equals("@") || next.Equals("*") || XPathLexer.RegexTest(next, @"(?![0 - 9])[\w]"))) { ((List<Dictionary<string, object>>)absoluteLocation["steps"]).Add(Step.parse(rootParser, lexer)); } }else { Dictionary<string, object> itm = new Dictionary<string, object>(); itm.Add("axis", XPathAnalyzer.AxisSpecifier.DESCENDANT_OR_SELF); Dictionary<string, object> test = new Dictionary<string, object>(); test.Add("type", XPathAnalyzer.NodeType.NODE); itm.Add("test", test); ((List<Dictionary<string, object>>)absoluteLocation["steps"]).Add(itm); ((List<Dictionary<string, object>>)absoluteLocation["steps"]).Add(Step.parse(rootParser, lexer)); } } return absoluteLocation; }
public static object parse(Expr rootParser, XPathLexer lexer) { Dictionary <string, object> relativeLocation = new Dictionary <string, object>(); relativeLocation.Add("type", XPathAnalyzer.ExprType.RELATIVE_LOCATION_PATH); relativeLocation.Add("steps", new List <Dictionary <string, object> >()); ((List <Dictionary <string, object> >)relativeLocation["steps"]).Add(Step.parse(rootParser, lexer)); while (!lexer.empty() && (!string.IsNullOrEmpty(lexer.peak()) && lexer.peak()[0] == '/')) { if (lexer.next().Equals("/")) { ((List <Dictionary <string, object> >)relativeLocation["steps"]).Add(Step.parse(rootParser, lexer)); } else { Dictionary <string, object> itm = new Dictionary <string, object>(); itm.Add("axis", XPathAnalyzer.AxisSpecifier.DESCENDANT_OR_SELF); Dictionary <string, object> test = new Dictionary <string, object>(); test.Add("type", XPathAnalyzer.NodeType.NODE); itm.Add("test", test); ((List <Dictionary <string, object> >)relativeLocation["steps"]).Add(itm); ((List <Dictionary <string, object> >)relativeLocation["steps"]).Add(Step.parse(rootParser, lexer)); } } return(relativeLocation); }
public static object parse(Expr rootParser, XPathLexer lexer) { if (FilterExpr.isValidOp(lexer)) { object filter = FilterExpr.parse(rootParser, lexer); if (!lexer.empty() && (lexer.peak()[0] == '/')) { Dictionary<string, object> path = new Dictionary<string, object>(); path.Add("type", XPathAnalyzer.ExprType.PATH); path.Add("filter", filter); path.Add("steps", new List<Dictionary<string, object>>()); while (!lexer.empty() && (lexer.peak()[0] == '/')) { if (lexer.next().Equals("//")) { Dictionary<string, object> itm = new Dictionary<string, object>(); itm.Add("axis", XPathAnalyzer.AxisSpecifier.DESCENDANT_OR_SELF); Dictionary<string, string> test = new Dictionary<string, string>(); test.Add("type", XPathAnalyzer.NodeType.NODE); itm.Add("test", test); ((List<Dictionary<string, object>>)path["steps"]).Add(itm); } ((List<Dictionary<string, object>>)path["steps"]).Add(Step.parse(rootParser, lexer)); } return path; } else { return filter; } } else { return LocationPath.parse(rootParser, lexer); } }
public static object parse(Expr rootParser, XPathLexer lexer) { if (FilterExpr.isValidOp(lexer)) { object filter = FilterExpr.parse(rootParser, lexer); if (!lexer.empty() && (lexer.peak()[0] == '/')) { Dictionary <string, object> path = new Dictionary <string, object>(); path.Add("type", XPathAnalyzer.ExprType.PATH); path.Add("filter", filter); path.Add("steps", new List <Dictionary <string, object> >()); while (!lexer.empty() && (lexer.peak()[0] == '/')) { if (lexer.next().Equals("//")) { Dictionary <string, object> itm = new Dictionary <string, object>(); itm.Add("axis", XPathAnalyzer.AxisSpecifier.DESCENDANT_OR_SELF); Dictionary <string, string> test = new Dictionary <string, string>(); test.Add("type", XPathAnalyzer.NodeType.NODE); itm.Add("test", test); ((List <Dictionary <string, object> >)path["steps"]).Add(itm); } ((List <Dictionary <string, object> >)path["steps"]).Add(Step.parse(rootParser, lexer)); } return(path); } else { return(filter); } } else { return(LocationPath.parse(rootParser, lexer)); } }
public static object parse(Expr rootParser, XPathLexer lexer) { Dictionary <string, object> absoluteLocation = new Dictionary <string, object>(); absoluteLocation.Add("type", XPathAnalyzer.ExprType.ABSOLUTE_LOCATION_PATH); while (!lexer.empty() && (lexer.peak()[0] == '/')) { if (!absoluteLocation.ContainsKey("steps")) { absoluteLocation.Add("steps", new List <Dictionary <string, object> >()); } if (lexer.next().Equals("/")) { var next = lexer.peak(); if (!lexer.empty() && (next.Equals(".") || next.Equals("..") || next.Equals("@") || next.Equals("*") || XPathLexer.RegexTest(next, @"(?![0 - 9])[\w]"))) { ((List <Dictionary <string, object> >)absoluteLocation["steps"]).Add(Step.parse(rootParser, lexer)); } } else { Dictionary <string, object> itm = new Dictionary <string, object>(); itm.Add("axis", XPathAnalyzer.AxisSpecifier.DESCENDANT_OR_SELF); Dictionary <string, object> test = new Dictionary <string, object>(); test.Add("type", XPathAnalyzer.NodeType.NODE); itm.Add("test", test); ((List <Dictionary <string, object> >)absoluteLocation["steps"]).Add(itm); ((List <Dictionary <string, object> >)absoluteLocation["steps"]).Add(Step.parse(rootParser, lexer)); } } return(absoluteLocation); }