Example #1
0
        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));
            }
        }
Example #2
0
 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));
     }
 }
Example #3
0
        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));
        }
Example #4
0
 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("|");
        }
Example #6
0
        public static ConsAnnotation AnnotateList(Cons lst, SourceSpan loc)
        {
            Cons stripped = Strip(lst);

            return(new ConsAnnotation(lst, new Cons(Filename, loc.ToString()), stripped));
        }
Example #7
0
 public static bool TryGetAtom(SourceSpan name, out SymbolAtom atom) =>
 TryGetAtom(name.ToString(), name, out atom);
Example #8
0
        public void to_string()
        {
            var s = new SourceSpan(new SourceLocation(10, 2, 5), 8);

            Assert.AreEqual("2:5-13", s.ToString());
        }
Example #9
0
        public static bool TryGetAtom(SourceSpan name, out SymbolAtom?atom)
#endif
        {
            return(TryGetAtom(name.ToString(), name, out atom));
        }