...
This commit is contained in:
@@ -177,6 +177,12 @@ public sealed class Tokenizer(string fileName, string contents)
|
||||
Consume();
|
||||
return new TokenSymbol(line, startColumn, column - startColumn, Symbol.Period);
|
||||
}
|
||||
case ':' when Peek(1) is ':':
|
||||
{
|
||||
Consume();
|
||||
Consume();
|
||||
return new TokenSymbol(line, startColumn, column - startColumn, Symbol.ColonColon);
|
||||
}
|
||||
case ':':
|
||||
{
|
||||
Consume();
|
||||
@@ -340,6 +346,9 @@ public sealed class Tokenizer(string fileName, string contents)
|
||||
"else" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.Else),
|
||||
"while" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.While),
|
||||
"return" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.Return),
|
||||
"module" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.Module),
|
||||
"import" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.Import),
|
||||
"export" => new TokenKeyword(line, startColumn, column - startColumn, Keyword.Export),
|
||||
"true" => new TokenBoolLiteral(line, startColumn, column - startColumn, true),
|
||||
"false" => new TokenBoolLiteral(line, startColumn, column - startColumn, false),
|
||||
_ => new TokenIdent(line, startColumn, column - startColumn, value)
|
||||
@@ -430,6 +439,7 @@ public enum Symbol
|
||||
Comma,
|
||||
Period,
|
||||
Colon,
|
||||
ColonColon,
|
||||
Caret,
|
||||
Bang,
|
||||
Equal,
|
||||
@@ -471,6 +481,9 @@ public enum Keyword
|
||||
Else,
|
||||
While,
|
||||
Return,
|
||||
Module,
|
||||
Import,
|
||||
Export,
|
||||
}
|
||||
|
||||
public sealed class TokenKeyword(int line, int column, int length, Keyword keyword) : Token(line, column, length)
|
||||
@@ -491,6 +504,7 @@ public static class TokenExtensions
|
||||
Symbol.Comma => ",",
|
||||
Symbol.Period => ",",
|
||||
Symbol.Colon => ":",
|
||||
Symbol.ColonColon => "::",
|
||||
Symbol.Caret => "^",
|
||||
Symbol.Bang => "!",
|
||||
Symbol.Equal => "=",
|
||||
@@ -531,6 +545,9 @@ public static class TokenExtensions
|
||||
Keyword.Else => "else",
|
||||
Keyword.While => "while",
|
||||
Keyword.Return => "return",
|
||||
Keyword.Module => "module",
|
||||
Keyword.Import => "import",
|
||||
Keyword.Export => "export",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(symbol), symbol, null)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user