Skip to content

Commit

Permalink
Started porting over SourceCodePrettyPrinter to C#
Browse files Browse the repository at this point in the history
  • Loading branch information
fholm committed Jul 4, 2011
1 parent 9a72301 commit e4c3d25
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Src/IronJS.Runtime/Errors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,40 @@

namespace IronJS.Runtime
{
internal static class SourceCodePrinter
{
private static string[] SplitLines(string input)
{
var cleanedInput = (input ?? "").Replace("\r\n", "\n").Replace("\r", "\n");
return System.Text.RegularExpressions.Regex.Split(cleanedInput, "\n");
}

private static string LineNumber(int padding, int input)
{
return (input.ToString()).PadLeft(padding, '0');
}

private static string MakeArrow(int length)
{
var builder = new StringBuilder(length).Insert(0, "-", length);
return builder + "^";
}

internal string PrettyPrintSourceError(Tuple<int, int> aboveBelow, Tuple<int, int> lineCol, string source)
{
var above = aboveBelow.Item1;
var below = aboveBelow.Item2;
var line = lineCol.Item1;
var column = lineCol.Item2;

throw new NotImplementedException();
}
}

public abstract class Error : Exception
{
public Error(string message)
: base(message)
: base(message ?? "<unknown>")
{

}
Expand Down

0 comments on commit e4c3d25

Please sign in to comment.