...
This commit is contained in:
@@ -58,7 +58,7 @@ public sealed class Tokenizer
|
||||
|
||||
Tokens.Add(ParseToken(current, _line, _column));
|
||||
}
|
||||
catch (TokenizerException e)
|
||||
catch (CompileException e)
|
||||
{
|
||||
Diagnostics.Add(e.Diagnostic);
|
||||
Next();
|
||||
@@ -95,7 +95,7 @@ public sealed class Tokenizer
|
||||
return ParseIdentifier(lineStart, columnStart);
|
||||
}
|
||||
|
||||
throw new TokenizerException(Diagnostic.Error($"Unknown token '{current}'").Build());
|
||||
throw new CompileException(Diagnostic.Error($"Unknown token '{current}'").Build());
|
||||
}
|
||||
|
||||
private Token ParseNumber(int lineStart, int columnStart)
|
||||
@@ -116,7 +116,7 @@ public sealed class Tokenizer
|
||||
|
||||
if (_index == digitStart)
|
||||
{
|
||||
throw new TokenizerException(Diagnostic
|
||||
throw new CompileException(Diagnostic
|
||||
.Error("Invalid hex literal, no digits found")
|
||||
.At(_fileName, _line, _column)
|
||||
.Build());
|
||||
@@ -141,7 +141,7 @@ public sealed class Tokenizer
|
||||
|
||||
if (_index == digitStart)
|
||||
{
|
||||
throw new TokenizerException(Diagnostic
|
||||
throw new CompileException(Diagnostic
|
||||
.Error("Invalid binary literal, no digits found")
|
||||
.At(_fileName, _line, _column)
|
||||
.Build());
|
||||
@@ -163,7 +163,7 @@ public sealed class Tokenizer
|
||||
{
|
||||
if (isFloat)
|
||||
{
|
||||
throw new TokenizerException(Diagnostic
|
||||
throw new CompileException(Diagnostic
|
||||
.Error("More than one period found in float literal")
|
||||
.At(_fileName, _line, _column)
|
||||
.Build());
|
||||
@@ -198,7 +198,7 @@ public sealed class Tokenizer
|
||||
{
|
||||
if (_index >= _content.Length)
|
||||
{
|
||||
throw new TokenizerException(Diagnostic
|
||||
throw new CompileException(Diagnostic
|
||||
.Error("Unclosed string literal")
|
||||
.At(_fileName, _line, _column)
|
||||
.Build());
|
||||
@@ -208,7 +208,7 @@ public sealed class Tokenizer
|
||||
|
||||
if (next == '\n')
|
||||
{
|
||||
throw new TokenizerException(Diagnostic
|
||||
throw new CompileException(Diagnostic
|
||||
.Error("Unclosed string literal (newline found)")
|
||||
.At(_fileName, _line, _column)
|
||||
.Build());
|
||||
@@ -375,14 +375,4 @@ public sealed class Tokenizer
|
||||
_index += count;
|
||||
_column += count;
|
||||
}
|
||||
}
|
||||
|
||||
public class TokenizerException : Exception
|
||||
{
|
||||
public Diagnostic Diagnostic { get; }
|
||||
|
||||
public TokenizerException(Diagnostic diagnostic) : base(diagnostic.Message)
|
||||
{
|
||||
Diagnostic = diagnostic;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user