Implemented for loops

This commit is contained in:
Eduard Urbach 2025-02-19 23:46:17 +01:00
parent ac03657307
commit d26bf9d1a9
Signed by: eduard
GPG key ID: 49226B848C78F6C8
16 changed files with 142 additions and 120 deletions

View file

@ -69,6 +69,7 @@ const (
Const // const
Else // else
Extern // extern
For // for
If // if
Import // import
Loop // loop

View file

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

View file

@ -23,6 +23,8 @@ func identifier(tokens List, buffer []byte, i Position) (List, Position) {
kind = Else
case "extern":
kind = Extern
case "for":
kind = For
case "import":
kind = Import
case "loop":