Implemented const keyword

This commit is contained in:
Eduard Urbach 2025-02-15 14:38:01 +01:00
parent 5f37a9e84a
commit 91a3ec9d52
Signed by: eduard
GPG key ID: 49226B848C78F6C8
21 changed files with 164 additions and 26 deletions

View file

@ -65,6 +65,7 @@ const (
___END_OPERATORS___ // </operators>
___KEYWORDS___ // <keywords>
Assert // assert
Const // const
Else // else
Extern // extern
If // if

View file

@ -25,10 +25,11 @@ func TestFunction(t *testing.T) {
}
func TestKeyword(t *testing.T) {
tokens := token.Tokenize([]byte("assert if import else extern loop return struct switch"))
tokens := token.Tokenize([]byte("assert const if import else extern loop return struct switch"))
expected := []token.Kind{
token.Assert,
token.Const,
token.If,
token.Import,
token.Else,

View file

@ -15,6 +15,8 @@ func identifier(tokens List, buffer []byte, i Position) (List, Position) {
switch string(identifier) {
case "assert":
kind = Assert
case "const":
kind = Const
case "if":
kind = If
case "else":