Skip to content

Commit

Permalink
update tokens and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 12, 2023
1 parent b4d546d commit e7bb138
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 13 additions & 16 deletions lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ func TestNextToken(t *testing.T) {
// `
// input := `IF DAY ODD, ADD "quite an odd day!".`
input := `
IF DAY ODD, ADD "quite an odd day!".
IF DAY EVEN, ADD "quite an odd day!".
IF DAY EVEN, ADD (
TITLE "Event!",
DESC "This is an event!",
IF DAY ODD, ADD (
TITLE "Hitting the gym!",
DESC "Chest!!!",
RED
).
ELSE, ADD (
TITLE "Other Event!",
DESC "This is another event!",
BLUE
TITLE "Rest day.",
GREY
).`

tests := []struct {
Expand All @@ -31,22 +31,22 @@ func TestNextToken(t *testing.T) {
}{
{token.IF, "IF"},
{token.DAY, "DAY"},
{token.ODD, "ODD"},
{token.EVEN, "EVEN"},
{token.COMMA, ","},
{token.ADD, "ADD"},
{token.STRING, "quite an odd day!"},
{token.PERIOD, "."},
{token.IF, "IF"},
{token.DAY, "DAY"},
{token.EVEN, "EVEN"},
{token.ODD, "ODD"},
{token.COMMA, ","},
{token.ADD, "ADD"},
{token.LPAREN, "("},
{token.TITLE, "TITLE"},
{token.STRING, "Event!"},
{token.STRING, "Hitting the gym!"},
{token.COMMA, ","},
{token.DESC, "DESC"},
{token.STRING, "This is an event!"},
{token.STRING, "Chest!!!"},
{token.COMMA, ","},

{token.RED, "RED"},
Expand All @@ -57,12 +57,9 @@ func TestNextToken(t *testing.T) {
{token.ADD, "ADD"},
{token.LPAREN, "("},
{token.TITLE, "TITLE"},
{token.STRING, "Other Event!"},
{token.COMMA, ","},
{token.DESC, "DESC"},
{token.STRING, "This is another event!"},
{token.STRING, "Rest day."},
{token.COMMA, ","},
{token.BLUE, "BLUE"},
{token.GREY, "GREY"},
{token.RPAREN, ")"},
{token.PERIOD, "."},
{token.EOF, ""},
Expand Down
2 changes: 2 additions & 0 deletions token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
RED = "RED"
BLUE = "BLUE"
GREEN = "GREEN"
GREY = "GREY"

// Operators
GThan = ">"
Expand Down Expand Up @@ -47,6 +48,7 @@ var keywords = map[string]TokenType{
"RED": RED,
"BLUE": BLUE,
"GREEN": GREEN,
"GREY": GREY,

"IF": IF,
"ELSE": ELSE,
Expand Down

0 comments on commit e7bb138

Please sign in to comment.