...
This commit is contained in:
@@ -55,13 +55,13 @@ public class Lexer
|
||||
};
|
||||
|
||||
private string _src = null!;
|
||||
private string _filePath = null!;
|
||||
private SourceFile _sourceFile;
|
||||
private int _index;
|
||||
|
||||
public List<Token> Lex(string src, string filePath)
|
||||
public List<Token> Lex(string src, SourceFile sourceFile)
|
||||
{
|
||||
_src = src;
|
||||
_filePath = filePath;
|
||||
_sourceFile = sourceFile;
|
||||
_index = 0;
|
||||
|
||||
List<Token> tokens = [];
|
||||
@@ -121,7 +121,7 @@ public class Lexer
|
||||
|
||||
if (documentation != null)
|
||||
{
|
||||
return new DocumentationToken(_filePath, startIndex, _index, documentation);
|
||||
return new DocumentationToken(_sourceFile, startIndex, _index, documentation);
|
||||
}
|
||||
|
||||
ConsumeWhitespace();
|
||||
@@ -144,20 +144,20 @@ public class Lexer
|
||||
|
||||
if (Keywords.TryGetValue(buffer, out var keywordSymbol))
|
||||
{
|
||||
return new SymbolToken(_filePath, startIndex, _index, keywordSymbol);
|
||||
return new SymbolToken(_sourceFile, startIndex, _index, keywordSymbol);
|
||||
}
|
||||
|
||||
if (Modifiers.TryGetValue(buffer, out var modifer))
|
||||
{
|
||||
return new ModifierToken(_filePath, startIndex, _index, modifer);
|
||||
return new ModifierToken(_sourceFile, startIndex, _index, modifer);
|
||||
}
|
||||
|
||||
if (buffer is "true" or "false")
|
||||
{
|
||||
return new LiteralToken(_filePath, startIndex, _index, NubPrimitiveType.Bool, buffer);
|
||||
return new LiteralToken(_sourceFile, startIndex, _index, NubPrimitiveType.Bool, buffer);
|
||||
}
|
||||
|
||||
return new IdentifierToken(_filePath, startIndex, _index, buffer);
|
||||
return new IdentifierToken(_sourceFile, startIndex, _index, buffer);
|
||||
}
|
||||
|
||||
if (char.IsDigit(current))
|
||||
@@ -195,7 +195,7 @@ public class Lexer
|
||||
}
|
||||
}
|
||||
|
||||
return new LiteralToken(_filePath, startIndex, _index, isFloat ? NubPrimitiveType.F64 : NubPrimitiveType.I64, buffer);
|
||||
return new LiteralToken(_sourceFile, startIndex, _index, isFloat ? NubPrimitiveType.F64 : NubPrimitiveType.I64, buffer);
|
||||
}
|
||||
|
||||
// TODO: Revisit this
|
||||
@@ -215,7 +215,7 @@ public class Lexer
|
||||
Next();
|
||||
}
|
||||
|
||||
return new SymbolToken(_filePath, startIndex, _index, chain.Value);
|
||||
return new SymbolToken(_sourceFile, startIndex, _index, chain.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class Lexer
|
||||
if (Chars.TryGetValue(current, out var charSymbol))
|
||||
{
|
||||
Next();
|
||||
return new SymbolToken(_filePath, startIndex, _index, charSymbol);
|
||||
return new SymbolToken(_sourceFile, startIndex, _index, charSymbol);
|
||||
}
|
||||
|
||||
if (current == '"')
|
||||
@@ -248,7 +248,7 @@ public class Lexer
|
||||
Next();
|
||||
}
|
||||
|
||||
return new LiteralToken(_filePath, startIndex, _index, NubPrimitiveType.String, buffer);
|
||||
return new LiteralToken(_sourceFile, startIndex, _index, NubPrimitiveType.String, buffer);
|
||||
}
|
||||
|
||||
throw new Exception($"Unknown character {current}");
|
||||
|
||||
Reference in New Issue
Block a user