Skip to content

Commit

Permalink
Semi and pipe tokens (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnstoppableMango authored Jan 15, 2025
1 parent 16c6a5f commit a5a63f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ const (
RBRACE // }
DOLLAR // $
COLON // :
SEMI // ;
COMMA // ,
PIPE // |
NEWLINE // \n
TAB // \t

Expand Down Expand Up @@ -119,7 +121,9 @@ var tokens = [...]string{
RBRACE: "}",
DOLLAR: "$",
COLON: ":",
SEMI: ";",
COMMA: ",",
PIPE: "|",
NEWLINE: "\n",
TAB: "\t",

Expand Down Expand Up @@ -279,7 +283,7 @@ func IsIdentifier(name string) bool {
return false
}
switch name {
case "(", ")", "{", "}", "$", ":", ",", "\n", "\t", "#":
case "(", ")", "{", "}", "$", ":", ";", ",", "\n", "\t", "|", "#":
fallthrough
case "=", ":=", "::=", ":::=", "?=", "!=":
return false
Expand Down
8 changes: 8 additions & 0 deletions token/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,18 @@ var _ = Describe("Token", func() {
Entry(nil, "file"),
Entry(nil, "value"),
Entry(nil, ""),
func(keyword string) {
Expect(token.IsIdentifier(keyword)).To(BeFalse())
},
)

DescribeTable("special characters",
Entry(nil, "("),
Entry(nil, ")"),
Entry(nil, "{"),
Entry(nil, "}"),
Entry(nil, ":"),
Entry(nil, ";"),
Entry(nil, "$"),
Entry(nil, "#"),
Entry(nil, ","),
Expand All @@ -524,6 +531,7 @@ var _ = Describe("Token", func() {
Entry(nil, "\t"),
Entry(nil, "?="),
Entry(nil, "!="),
Entry(nil, "|"),
func(keyword string) {
Expect(token.IsIdentifier(keyword)).To(BeFalse())
},
Expand Down

0 comments on commit a5a63f2

Please sign in to comment.