Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 5
0
        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("|");
        }
Ejemplo n.º 6
0
        public static ConsAnnotation AnnotateList(Cons lst, SourceSpan loc)
        {
            Cons stripped = Strip(lst);

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

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