public static Annotation Annotate(object obj, SourceSpan loc) { switch (obj) { case Cons cons: return(AnnotateList(cons, loc)); case object[] arr: var stripped = Array.ConvertAll(arr, Strip); return(new Annotation(arr, new Cons(Filename, loc.ToString()), stripped)); default: return(new Annotation(obj, new Cons(Filename, loc.ToString()), obj)); } }
public static Annotation Annotate(object obj, SourceSpan loc) { if (obj is Cons) { return(AnnotateList(obj as Cons, loc)); } else if (obj is object[]) { var arr = (object[])obj; var stripped = Array.ConvertAll(arr, x => Strip(x)); return(new Annotation(obj, new Cons(Filename, loc.ToString()), stripped)); } else { return(new Annotation(obj, new Cons(Filename, loc.ToString()), obj)); } }
public AndConstraint <SourceSpanAssertions> Be(SourceSpan span, string because = "", params object[] becauseArgs) { Execute.Assertion.ForCondition(Subject.HasValue && RangeEquals(Subject.Value, span)) .BecauseOf(because, becauseArgs) .FailWith($"Expected range to be {span.ToString()}{{reason}}, but found {SubjectString}."); return(new AndConstraint <SourceSpanAssertions>(this)); }
public static bool TryGetAtom(SourceSpan name, out SymbolAtom atom) { if (symbols.TryGetValue(name.ToString(), out var temp)) { var symbol = temp(name); atom = new SymbolAtom(name, symbol, symbol.Type); return(true); } atom = null; return(false); }
private static void AppendMappingLocation(StringBuilder builder, SourceSpan location, string content) { builder .AppendLine(location.ToString()) .Append("|"); for (var i = 0; i < location.Length; i++) { builder.Append(content[location.AbsoluteIndex + i]); } builder.AppendLine("|"); }
public static ConsAnnotation AnnotateList(Cons lst, SourceSpan loc) { Cons stripped = Strip(lst); return(new ConsAnnotation(lst, new Cons(Filename, loc.ToString()), stripped)); }
public static bool TryGetAtom(SourceSpan name, out SymbolAtom atom) => TryGetAtom(name.ToString(), name, out atom);
public void to_string() { var s = new SourceSpan(new SourceLocation(10, 2, 5), 8); Assert.AreEqual("2:5-13", s.ToString()); }
public static bool TryGetAtom(SourceSpan name, out SymbolAtom?atom) #endif { return(TryGetAtom(name.ToString(), name, out atom)); }