Skip to content

Commit

Permalink
Merge pull request #3 from mengzhuo/main
Browse files Browse the repository at this point in the history
set nya as 0
  • Loading branch information
EllaMuskTeyvat authored Mar 11, 2024
2 parents e62e734 + f02ef27 commit 99dc6ea
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
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 @@ -65,7 +65,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

0 comments on commit 99dc6ea

Please sign in to comment.