Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set nya as 0 #3

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@

# Dependency directories (remove the comment below to include it)
# vendor/
main.wasm
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sada

* `da` True in boolean
* `nye` False in boolean
* `nya` null, nil
* `nya` null, nil, 0
* `unu` one, 1
* `du` two, 2
* `unudu` three, 3
Expand Down
3 changes: 3 additions & 0 deletions elementary.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ func truthExpr(t bool) *Expr {
}

func (c *Context) getNumber(expr *Expr) int {
if expr.isNya() {
return 0
}
if !expr.isNumber() {
errorf("expect number; got %v", expr)
}
Expand Down
4 changes: 4 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ func (e *Expr) isTrue() bool {
return e != nil && e.sada == tokDa
}

func (e *Expr) isNya() bool {
return e == nil || e.sada == tokNya
}

func (e *Expr) length() int {
if e == nil {
return 0
Expand Down
Loading