Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor kariuki committed Oct 17, 2023
2 parents b243bd2 + 7732a4b commit b2de172
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 26 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Go

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
id: go

- name: Test
run: go mod tidy && make test

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.21

- name: Test
run: go mod tidy && make test
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ nuru
Notes.md
tutorials/en/*
config.json
*local*

# For Nuru executables
/nuru
/Nuru

dist/
47 changes: 47 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
project_name: nuru
before:
hooks:
- go mod tidy
- go generate ./...

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
- android
ldflags:
- '-s -w'
ignore:
- goos: android
goarch: 386

archives:
- format: tar.gz
name_template: >-
nuru_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

nfpms:
- maintainer: "AvicennaJr"
homepage: "https://nuruprogramming.org"
description: "Nuru is a programming language built from the ground up"
formats:
- deb
file_name_template: "{{ .ProjectName }}.{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
2 changes: 1 addition & 1 deletion evaluator/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var builtins = map[string]*object.Builtin{
"aina": {
Fn: func(args ...object.Object) object.Object {
if len(args) != 1 {
return newError("Samahani, tunahitaji Hoja 1, wewe umeweka %d", len(args))
return newError("Samahani, tunahitaji hoja 1, wewe umeweka %d", len(args))
}

return &object.String{Value: string(args[0].Type())}
Expand Down
8 changes: 4 additions & 4 deletions evaluator/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func Eval(node ast.Node, env *object.Environment) object.Object {
}
array.Elements[idx.Value] = value
} else {
return newError("Hauwezi kufanya opereshen hii na %#v", index)
return newError("Hauwezi kufanya operesheni hii na %#v", index)
}
} else if hash, ok := obj.(*object.Dict); ok {
key := Eval(ie.Index, env)
Expand All @@ -191,13 +191,13 @@ func Eval(node ast.Node, env *object.Environment) object.Object {
hashed := hashKey.HashKey()
hash.Pairs[hashed] = object.DictPair{Key: key, Value: value}
} else {
return newError("Hauwezi kufanya opereshen hii na %T", key)
return newError("Hauwezi kufanya operesheni hii na %T", key)
}
} else {
return newError("%T haifanyi operation hii", obj)
return newError("%T haifanyi operesheni hii", obj)
}
} else {
return newError("Tumia neno kama variable, sio %T", left)
return newError("Tumia neno kama kibadala, sio %T", left)
}

}
Expand Down
14 changes: 7 additions & 7 deletions evaluator/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,19 @@ func TestErrorHandling(t *testing.T) {
},
{
"-kweli",
"Mstari 1: Operesheni Haielweki: -BOOLEAN",
"Mstari 1: Operesheni Haieleweki: -BOOLEAN",
},
{
"kweli + sikweli",
"Mstari 1: Operesheni Haielweki: BOOLEAN + BOOLEAN",
"Mstari 1: Operesheni Haieleweki: BOOLEAN + BOOLEAN",
},
{
"5; kweli + sikweli; 5",
"Mstari 1: Operesheni Haielweki: BOOLEAN + BOOLEAN",
"Mstari 1: Operesheni Haieleweki: BOOLEAN + BOOLEAN",
},
{
"kama (10 > 1) { kweli + sikweli;}",
"Mstari 1: Operesheni Haielweki: BOOLEAN + BOOLEAN",
"Mstari 1: Operesheni Haieleweki: BOOLEAN + BOOLEAN",
},
{
`
Expand All @@ -238,19 +238,19 @@ kama (10 > 1) {
rudisha 1;
}
`,
"Mstari 4: Operesheni Haielweki: BOOLEAN + BOOLEAN",
"Mstari 4: Operesheni Haieleweki: BOOLEAN + BOOLEAN",
},
{
"bangi",
"Mstari 1: Neno Halifahamiki: bangi",
},
{
`"Habari" - "Habari"`,
"Mstari 1: Operesheni Haielweki: NENO - NENO",
"Mstari 1: Operesheni Haieleweki: NENO - NENO",
},
{
`{"jina": "Avi"}[unda(x) {x}];`,
"Mstari 1: Samahani, UNDO (FUNCTION) haitumiki kama key",
"Mstari 1: Samahani, UNDO (FUNCTION) haitumiki kama ufunguo",
},
}

Expand Down
4 changes: 2 additions & 2 deletions evaluator/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func evalImportFile(name string, ident *ast.Identifier, env *object.Environment)
addSearchPath("")
filename := findFile(name)
if filename == "" {
return newError("Module %s haipo", name)
return newError("Moduli %s haipo", name)
}
var scope *object.Environment
scope, err := evaluateFile(filename, env)
Expand Down Expand Up @@ -70,7 +70,7 @@ func evaluateFile(file string, env *object.Environment) (*object.Environment, ob
p := parser.New(l)
program := p.ParseProgram()
if len(p.Errors()) != 0 {
return nil, &object.Error{Message: fmt.Sprintf("Pakeji %s ina errors zifuatozo:\n%s", file, strings.Join(p.Errors(), "\n"))}
return nil, &object.Error{Message: fmt.Sprintf("Pakeji %s ina makosa yafuatayo:\n%s", file, strings.Join(p.Errors(), "\n"))}
}

scope := object.NewEnvironment()
Expand Down
2 changes: 1 addition & 1 deletion evaluator/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func evalDictIndexExpression(dict, index object.Object, line int) object.Object

key, ok := index.(object.Hashable)
if !ok {
return newError("Mstari %d: Samahani, %s haitumiki kama key", line, index.Type())
return newError("Mstari %d: Samahani, %s haitumiki kama ufunguo", line, index.Type())
}

pair, ok := dictObject.Pairs[key.HashKey()]
Expand Down
12 changes: 6 additions & 6 deletions evaluator/infix.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func evalInfixExpression(operator string, left, right object.Object, line int) o
line, left.Type(), operator, right.Type())

default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s",
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s",
line, left.Type(), operator, right.Type())
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func evalFloatIntegerInfixExpression(operator string, left, right object.Object,
case "!=":
return nativeBoolToBooleanObject(leftVal != rightVal)
default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s",
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s",
line, left.Type(), operator, right.Type())
}

Expand All @@ -156,7 +156,7 @@ func evalStringInfixExpression(operator string, left, right object.Object, line
case "!=":
return nativeBoolToBooleanObject(leftVal != rightVal)
default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s", line, left.Type(), operator, right.Type())
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s", line, left.Type(), operator, right.Type())
}
}

Expand All @@ -170,7 +170,7 @@ func evalBooleanInfixExpression(operator string, left, right object.Object, line
case "||":
return nativeBoolToBooleanObject(leftVal || rightVal)
default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s", line, left.Type(), operator, right.Type())
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s", line, left.Type(), operator, right.Type())
}
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func evalFloatInfixExpression(operator string, left, right object.Object, line i
case "!=":
return nativeBoolToBooleanObject(leftVal != rightVal)
default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s",
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s",
line, left.Type(), operator, right.Type())
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func evalIntegerInfixExpression(operator string, left, right object.Object, line
case "!=":
return nativeBoolToBooleanObject(leftVal != rightVal)
default:
return newError("Mstari %d: Operesheni Haielweki: %s %s %s",
return newError("Mstari %d: Operesheni Haieleweki: %s %s %s",
line, left.Type(), operator, right.Type())
}
}
6 changes: 3 additions & 3 deletions evaluator/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func evalMinusPrefixOperatorExpression(right object.Object, line int) object.Obj
return &object.Float{Value: -obj.Value}

default:
return newError("Mstari %d: Operesheni Haielweki: -%s", line, right.Type())
return newError("Mstari %d: Operesheni Haieleweki: -%s", line, right.Type())
}
}
func evalPlusPrefixOperatorExpression(right object.Object, line int) object.Object {
Expand All @@ -25,7 +25,7 @@ func evalPlusPrefixOperatorExpression(right object.Object, line int) object.Obje
return &object.Float{Value: obj.Value}

default:
return newError("Mstari %d: Operesheni Haielweki: +%s", line, right.Type())
return newError("Mstari %d: Operesheni Haieleweki: +%s", line, right.Type())
}
}

Expand All @@ -38,6 +38,6 @@ func evalPrefixExpression(operator string, right object.Object, line int) object
case "+":
return evalPlusPrefixOperatorExpression(right, line)
default:
return newError("Mstari %d: Operesheni haieleweki: %s%s", line, operator, right.Type())
return newError("Mstari %d: Operesheni Haieleweki: %s%s", line, operator, right.Type())
}
}
2 changes: 1 addition & 1 deletion evaluator/property.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ func evalPropertyAssignment(name *ast.PropertyExpression, val object.Object, env
obj.Env.Set(prop, val)
return NULL
default:
return newError("Imeshindikana ku assign kwenye package %s", left.Type())
return newError("Imeshindikana kuweka kwenye pakiti %s", left.Type())
}
}
2 changes: 2 additions & 0 deletions token/token.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This is where we define our tokens

package token

type TokenType string
Expand Down

0 comments on commit b2de172

Please sign in to comment.