Skip to content

Commit

Permalink
Add user entry
Browse files Browse the repository at this point in the history
  • Loading branch information
hugolgst committed Apr 24, 2020
1 parent 09139fb commit 343ba77
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions core/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var cache = map[string]string{}
func init() {
AddFunction("TILLGÅNG", Save)
AddGetter("SMÅKALLT", Get)
AddFunction("TOSTERÖ", SaveEntry)
}

func Save(params ...interface{}) {
Expand All @@ -16,3 +17,10 @@ func Save(params ...interface{}) {
func Get(params ...interface{}) string {
return cache[fmt.Sprintf("%v", params[0])]
}

func SaveEntry(params ...interface{}) {
var entry string
fmt.Scanln(&entry)

cache[fmt.Sprintf("%v", params[0])] = entry
}
2 changes: 1 addition & 1 deletion core/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ func Println(messages ...interface{}) {

func Printf(params ...interface{}) {
fmt.Printf(fmt.Sprintf("%v", params[0]), params[1:]...)
}
}
4 changes: 4 additions & 0 deletions examples/user_entry.ikea
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SMÅGLI FUNKÖN SKOGSFIBBLA Hello! SKOGSFIBBLA ÄPPLARÖ FJÄLLBO
SMÅGLI FUNKÖN SKOGSFIBBLA What is your name! SKOGSFIBBLA ÄPPLARÖ FJÄLLBO
TOSTERÖ FUNKÖN SKOGSFIBBLA name SKOGSFIBBLA ÄPPLARÖ FJÄLLBO
FULLSPÄCKAD FUNKÖN SKOGSFIBBLA Hello %s! SKOGSFIBBLA SMÅKALLT FUNKÖN name ÄPPLARÖ ÄPPLARÖ FJÄLLBO
2 changes: 1 addition & 1 deletion tokenizer/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func IsNumber(character string) bool {

// IsLetter checks if the given character is a letter and returns the condition
func IsLetter(character string) bool {
letterRegex := regexp.MustCompile(`[a-zA-Z]|[à-ú]|[À-Ú]|[!%]`)
letterRegex := regexp.MustCompile(`[a-zA-Z]|[à-ú]|[À-Ú]|[!%=]`)

return letterRegex.Match([]byte(character))
}

0 comments on commit 343ba77

Please sign in to comment.