Add JSON path to CLI and refactored
This commit is contained in:
@@ -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}'."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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}'.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
16
DevDisciples.Parsing/SyntaxException.cs
Normal file
16
DevDisciples.Parsing/SyntaxException.cs
Normal 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user