...
This commit is contained in:
@@ -11,14 +11,15 @@ public sealed class Parser
|
||||
private Token? CurrentToken => _tokenIndex < _tokens.Count ? _tokens[_tokenIndex] : null;
|
||||
private bool HasToken => CurrentToken != null;
|
||||
|
||||
public List<Diagnostic> Diagnostics { get; } = [];
|
||||
public List<Diagnostic> Diagnostics { get; set; } = [];
|
||||
|
||||
public SyntaxTree Parse(List<Token> tokens)
|
||||
{
|
||||
Diagnostics.Clear();
|
||||
_tokens = tokens;
|
||||
_tokenIndex = 0;
|
||||
|
||||
Diagnostics = [];
|
||||
|
||||
var topLevelSyntaxNodes = new List<TopLevelSyntaxNode>();
|
||||
|
||||
while (HasToken)
|
||||
|
||||
@@ -4,25 +4,23 @@ namespace NubLang.Syntax;
|
||||
|
||||
public sealed class Tokenizer
|
||||
{
|
||||
private readonly string _fileName;
|
||||
private readonly string _content;
|
||||
private string _fileName = null!;
|
||||
private string _content = null!;
|
||||
private int _index;
|
||||
private int _line = 1;
|
||||
private int _column = 1;
|
||||
|
||||
public Tokenizer(string fileName, string content)
|
||||
public List<Diagnostic> Diagnostics { get; set; } = new(16);
|
||||
public List<Token> Tokens { get; set; } = new(256);
|
||||
|
||||
public void Tokenize(string fileName, string content)
|
||||
{
|
||||
_fileName = fileName;
|
||||
_content = content;
|
||||
}
|
||||
|
||||
public List<Diagnostic> Diagnostics { get; } = new(16);
|
||||
public List<Token> Tokens { get; } = new(256);
|
||||
Diagnostics = [];
|
||||
Tokens = [];
|
||||
|
||||
public void Tokenize()
|
||||
{
|
||||
Diagnostics.Clear();
|
||||
Tokens.Clear();
|
||||
_index = 0;
|
||||
_line = 1;
|
||||
_column = 1;
|
||||
|
||||
Reference in New Issue
Block a user