/// <summary> /// Return wich Destination is the parameter /// </summary> /// <param name="s">To parse</param> /// <returns>The actual destination</returns> public SelfLanguageDestination IsCommand(string s) { if (Ram.Match(s).Success) { return(SelfLanguageDestination.Ram); } else if (Stack.Match(s).Success) { return(SelfLanguageDestination.Stack); } else if (StackMultiChar.Match(s).Success) { return(SelfLanguageDestination.StackMultiChar); } else if (Number.Match(s).Success) { return(SelfLanguageDestination.Number); } else if (Here.Match(s).Success) { return(SelfLanguageDestination.Here); } else if (Compare.Match(s).Success) { return(SelfLanguageDestination.Compare); } else { return(SelfLanguageDestination.None); } }
private PathExpression GeneratePath(ParseTreeNode node) { PathExpression result; switch (node.Term.Name) { case "PathRoot": result = new Root(); break; case "PathName": result = new Name(node.ChildNodes[0].Token.Text); break; case "PathLocal": result = new Here(); break; case "PathParent": result = new Parent(); break; case "PathAll": result = new All(); break; default: throw new NotImplementedException(node.ToString()); } var j = 0; if (node.Term.Name == "PathName") { j = 1; } if (node.Term.Name != "PathRoot" && node.ChildNodes[j].ChildNodes.Count > 0) //.Term.Name == "Filter" { result.AddFilter(GenerateExpression(node.ChildNodes[j].ChildNodes[0])); } var i = 1; if (node.Term.Name == "PathName") { i = 2; } else if (node.Term.Name == "PathRoot") { i = 0; } if (node.ChildNodes.Count > i) { result.Extend(GeneratePath(node.ChildNodes[i])); } return(result); }