﻿using System;
using Pixie.Terminal;
using Pixie.Loyc;
using Pixie;
using Pixie.Transforms;
using Loyc.Syntax;
using Loyc;
using Loyc.Ecs;
using Loyc.Collections;
using Pixie.Markup;

namespace LoycInterop
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            // This example demonstrates how to translate an error
            // generated by Loyc into a Pixie diagnostic.

            // First, acquire a terminal log. We'll configure it to
            // turn everything it sees into a diagnostic.
            var log = new TransformLog(
                TerminalLog.Acquire(),
                new Func<LogEntry, LogEntry>[]
                {
                    MakeDiagnostic
                });

            // Create a message sink that redirects messages to the log.
            var messageSink = new PixieMessageSink(log);

            // Next, we'll create a C# source file with a syntax error
            // in it.
            var file = new SourceFile<ICharSource>(new UString("int int x = 10;"), "input.cs");

            // Now, parse the document and watch the syntax error emerge
            // as a Pixie diagnostic.
            EcsLanguageService.Value.Parse(
                file.Text,
                file.FileName,
                messageSink,
                null,
                true).ToArray<LNode>();
        }

        private static LogEntry MakeDiagnostic(LogEntry entry)
        {
            var newEntry = DiagnosticExtractor.Transform(entry, "program");
            return new LogEntry(newEntry.Severity, WrapBox.WordWrap(newEntry.Contents));
        }
    }
}

﻿using System;
using Pixie.Terminal;
using Pixie.Loyc;
using Pixie;
using Pixie.Transforms;
using Loyc.Syntax;
using Loyc;
using Loyc.Ecs;
using Loyc.Collections;
using Pixie.Markup;

namespace LoycInterop
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            // This example demonstrates how to translate an error
            // generated by Loyc into a Pixie diagnostic.

            // First, acquire a terminal log. We'll configure it to
            // turn everything it sees into a diagnostic.
            var log = new TransformLog(
                TerminalLog.Acquire(),
                new Func<LogEntry, LogEntry>[]
                {
                    MakeDiagnostic
                });

            // Create a message sink that redirects messages to the log.
            var messageSink = new PixieMessageSink(log);

            // Next, we'll create a C# source file with some syntax errors
            // in it.
            var file = new SourceFile<ICharSource>(new UString("int int x = 10; class A"), "input.cs");

            // Now, parse the document and watch the syntax error emerge
            // as a Pixie diagnostic.
            EcsLanguageService.Value.Parse(
                file.Text,
                file.FileName,
                messageSink,
                null,
                true).ToArray<LNode>();
        }

        private static LogEntry MakeDiagnostic(LogEntry entry)
        {
            var newEntry = DiagnosticExtractor.Transform(entry, "program");
            return new LogEntry(newEntry.Severity, WrapBox.WordWrap(newEntry.Contents));
        }
    }
}

Add another error message to LoycInterop example
Add another error message to LoycInterop example
