Add JSON path to CLI and refactored

This commit is contained in:
2024-09-28 13:29:53 +02:00
parent 82a59eebd2
commit dc7fda1eed
39 changed files with 188 additions and 124 deletions

View File

@@ -73,7 +73,7 @@ public abstract partial class Lexer<TToken> where TToken : Enum
if (src.Ended())
{
throw new ParsingException(
throw new SyntaxException(
$"[line: {src.Line}, column: {src.Column}] Unterminated string near '{src.Last}'."
);
}
@@ -117,7 +117,7 @@ public abstract partial class Lexer<TToken> where TToken : Enum
if (src.Ended())
{
throw new ParsingException(
throw new SyntaxException(
$"[line: {src.Line}, column: {src.Column}] Unterminated string near '{src.Last}'."
);
}

View File

@@ -25,7 +25,7 @@ public abstract partial class Lexer<TToken> where TToken : Enum
if (!matched)
{
Report.Halt(ctx.Source, $"Unexpected character '{ctx.Source.Current}'.");
Report.SyntaxHalt(ctx.Source, $"Unexpected character '{ctx.Source.Current}'.");
}
}

View File

@@ -91,11 +91,11 @@ public class ParserContext<TToken> : ParsableStream<Lexer<TToken>.Token> where T
public Exception Error(string message)
{
return new ParsingException(Report.FormatMessage(Current, message));
return new SyntaxException(Report.FormatMessage(Current, message));
}
public Exception Error(Lexer<TToken>.Token token, string message)
{
return new ParsingException(Report.FormatMessage(token, message));
return new SyntaxException(Report.FormatMessage(token, message));
}
}
}

View File

@@ -1,16 +0,0 @@
namespace DevDisciples.Parsing;
public class ParsingException : Exception
{
public ParsingException()
{
}
public ParsingException(string? message) : base(message)
{
}
public ParsingException(string? message, Exception? innerException) : base(message, innerException)
{
}
}

View File

@@ -2,14 +2,14 @@
public static class Report
{
public static ParsingException Error(ISourceLocation token, string message)
public static SyntaxException SyntaxException(ISourceLocation token, string message)
{
return new ParsingException(FormatMessage(token, message));
return new SyntaxException(FormatMessage(token, message));
}
public static void Halt(ISourceLocation token, string message)
public static void SyntaxHalt(ISourceLocation token, string message)
{
throw new ParsingException(FormatMessage(token, message));
throw new SyntaxException(FormatMessage(token, message));
}
public static string FormatMessage(ISourceLocation token, string msg)

View File

@@ -0,0 +1,16 @@
namespace DevDisciples.Parsing;
public class SyntaxException : Exception
{
public SyntaxException()
{
}
public SyntaxException(string? message) : base(message)
{
}
public SyntaxException(string? message, Exception? innerException) : base(message, innerException)
{
}
}