public KeyValuePair <string, PathType>?CompileCurrent(TokenzierContext context, int index, out Func <IMorestachioError> errProducer) { if (CurrentPart == ".") { PathParts.Add(null, PathType.SelfAssignment); } else if (CurrentPart == "../") { PathParts.Add(null, PathType.ParentSelector); } else if (CurrentPart == "~") { PathParts.Add(null, PathType.RootSelector); } else if (CurrentPart == "?") { PathParts.Add(null, PathType.ObjectSelector); } else if (CurrentPart.Trim() != string.Empty) { if (!ComputeCurrentPart(context, index, out errProducer)) { errProducer = () => ( new InvalidPathSyntaxError(context.CurrentLocation.Offset(index) .AddWindow(new CharacterSnippedLocation(1, index, CurrentPart)), CurrentPart, "Invalid character")); return(default);
public IList <KeyValuePair <string, PathType> > Compile(TokenzierContext context, int index) { if (CurrentPart == ".") { PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.SelfAssignment)); } else if (CurrentPart == "../") { PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.ParentSelector)); } else if (CurrentPart == "~") { PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.RootSelector)); } else if (CurrentPart == "?") { PathParts.Add(new KeyValuePair <string, PathType>(null, PathType.ObjectSelector)); } else if (CurrentPart.Trim() != "") { if (CurrentPartIsNumber) { PathParts.Add(new KeyValuePair <string, PathType>(CurrentPart, PathType.Number)); } else { if (!ComputeCurrentPart(context, index)) { return(new KeyValuePair <string, PathType> [0]); } } } if (PathParts.Count > 1 && PathParts.Last().Value == PathType.SelfAssignment) { PathParts.Remove(PathParts.Last()); } //if (!PathParts.Any()) //{ // hasError = 0; // return PathParts; //} CurrentPart = ""; return(PathParts); }