diff options
| author | ayyansea <ayyansea@gmail.com> | 2024-11-18 21:53:29 +0300 |
|---|---|---|
| committer | ayyansea <ayyansea@gmail.com> | 2024-11-18 21:53:29 +0300 |
| commit | 574e76ae935c4931ec50b14a94dee930ed6f3d5a (patch) | |
| tree | a289a98536930cd90a0d8e7e05420f3a35934923 /internal/token/linked_token_list.go | |
| parent | d741a3187f0e8abb00ee34356b3e61ab9087c0d9 (diff) | |
feat: restructure project + add a basic cli arg parser
Diffstat (limited to 'internal/token/linked_token_list.go')
| -rw-r--r-- | internal/token/linked_token_list.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/token/linked_token_list.go b/internal/token/linked_token_list.go new file mode 100644 index 0000000..5fe42a9 --- /dev/null +++ b/internal/token/linked_token_list.go @@ -0,0 +1,36 @@ +package token + +type LinkedTokenList struct { + head, tail *Token +} + +func (lts *LinkedTokenList) GetHead() *Token { + return lts.head +} + +func (lts *LinkedTokenList) GetTail() *Token { + return lts.tail +} + +func (lts *LinkedTokenList) AddToken(content string) { + newToken := &Token{ + content: content, + prev: nil, + next: nil, + } + + if lts.head == nil { + lts.head = newToken + lts.tail = newToken + } else { + newToken.SetPreviousToken(lts.tail) + lts.tail.SetNextToken(newToken) + lts.tail = newToken + } +} + +func SliceToLinkedTokenSlice(slice []string, tokenSlice *LinkedTokenList) { + for _, item := range slice { + tokenSlice.AddToken(item) + } +} |
