diagnostic
This commit is contained in:
@@ -1,45 +1,12 @@
|
||||
using Compiler;
|
||||
|
||||
const string contents = """
|
||||
struct person {
|
||||
age: i32
|
||||
name: string
|
||||
}
|
||||
var file = File.ReadAllText("test.nub");
|
||||
|
||||
func main(: i32 {
|
||||
let x: i32 = 23
|
||||
x = 24
|
||||
|
||||
if true {
|
||||
x = 49
|
||||
} else {
|
||||
x = 3
|
||||
}
|
||||
|
||||
let i: i32 = 0
|
||||
|
||||
x = 1 + 2 * 34
|
||||
|
||||
while i < 10 {
|
||||
i = i + 1
|
||||
x = i
|
||||
}
|
||||
|
||||
let me: person = struct person { age = 21 name = "Oliver" }
|
||||
|
||||
do_something(me.name)
|
||||
return x
|
||||
}
|
||||
|
||||
func do_something(text: string): void {
|
||||
}
|
||||
""";
|
||||
|
||||
var tokens = Tokenizer.Tokenize("test.nub", contents, out var tokenizerDiagnostics);
|
||||
var tokens = Tokenizer.Tokenize("test.nub", file, out var tokenizerDiagnostics);
|
||||
|
||||
foreach (var diagnostic in tokenizerDiagnostics)
|
||||
{
|
||||
Console.WriteLine(diagnostic.Message);
|
||||
DiagnosticFormatter.Print(diagnostic, Console.Error);
|
||||
}
|
||||
|
||||
if (tokenizerDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
|
||||
@@ -51,7 +18,7 @@ var nodes = Parser.Parse("test.nub", tokens, out var parserDiagnostics);
|
||||
|
||||
foreach (var diagnostic in parserDiagnostics)
|
||||
{
|
||||
Console.WriteLine(diagnostic.Message);
|
||||
DiagnosticFormatter.Print(diagnostic, Console.Error);
|
||||
}
|
||||
|
||||
if (parserDiagnostics.Any(x => x.Severity == DiagnosticSeverity.Error))
|
||||
|
||||
Reference in New Issue
Block a user