Skip to content

Commit

Permalink
feat:array lexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Houcine EL ADDALI committed Jan 24, 2024
1 parent 50d0ebf commit 0d83531
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func (l *Lexer) NextToken() token.Token {
tok = token.CreateToken(token.LCB, string(l.char))
case '}':
tok = token.CreateToken(token.RCB, string(l.char))
case '[':
tok = token.CreateToken(token.RB, string(l.char))
case ']':
tok = token.CreateToken(token.LB, string(l.char))
case ',':
tok = token.CreateToken(token.COMMA, string(l.char))
case ';':
Expand Down
8 changes: 8 additions & 0 deletions internal/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ var (
{expectedTokenType: token.INT, expectedValue: "10"},
{expectedTokenType: token.DECREMENT, expectedValue: "--"},
{expectedTokenType: token.S_COLON, expectedValue: ";"},

{expectedTokenType: token.RB, expectedValue: "["},
{expectedTokenType: token.INT, expectedValue: "2222"},
{expectedTokenType: token.COMMA, expectedValue: ","},
{expectedTokenType: token.INT, expectedValue: "7777"},
{expectedTokenType: token.LB, expectedValue: "]"},
{expectedTokenType: token.S_COLON, expectedValue: ";"},
}

NextData0 = []struct {
Expand Down Expand Up @@ -263,6 +270,7 @@ var (
10 >= 0;
10++;
10--;
[2222,7777];
`

Mock1 = `def val1 = 30;
Expand Down
2 changes: 2 additions & 0 deletions internal/token/token_ctes.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (

LCB = 24 // {
RCB = 25 // }
RB = 26 // [
LB = 27 // ]

// KEYWORDS [100,110]
FUNCTION = 100 // function keyword
Expand Down

0 comments on commit 0d83531

Please sign in to comment.