Skip to content

Commit

Permalink
prepared to release
Browse files Browse the repository at this point in the history
  • Loading branch information
odino committed Mar 30, 2021
1 parent 6fd5e8f commit 90d940f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

<p align="center">
<a href="https://github.com/abs-lang/abs"><img alt="GitHub branch checks state" src="https://img.shields.io/github/checks-status/abs-lang/abs/master"></a>
<a href="https://github.com/abs-lang/abs"><img alt="GitHub Workflow Status (branch)" src="https://img.shields.io/github/workflow/status/abs-lang/abs/tests/master"></a>
<a href="https://github.com/abs-lang/abs"><img alt="License" src="https://img.shields.io/github/license/abs-lang/abs.svg"></a>
<a href="https://github.com/abs-lang/abs"><img alt="Version" src="https://img.shields.io/github/release-pre/abs-lang/abs.svg"></a>
<img alt="undefined" src="https://img.shields.io/github/release-date/abs-lang/abs.svg?style=flat">
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.1
2.4.2
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>

<p align="center">
<a href="https://github.com/abs-lang/abs"><img alt="GitHub branch checks state" src="https://img.shields.io/github/checks-status/abs-lang/abs/master"></a>
<a href="https://github.com/abs-lang/abs"><img alt="GitHub Workflow Status (branch)" src="https://img.shields.io/github/workflow/status/abs-lang/abs/tests/master"></a>
<a href="https://github.com/abs-lang/abs"><img alt="License" src="https://img.shields.io/github/license/abs-lang/abs.svg"></a>
<a href="https://github.com/abs-lang/abs"><img alt="Version" src="https://img.shields.io/github/release-pre/abs-lang/abs.svg"></a>
<img href="https://github.com/abs-lang/abs/releases" alt="undefined" src="https://img.shields.io/github/release-date/abs-lang/abs.svg?style=flat">
Expand Down
Binary file modified docs/abs.wasm
100644 → 100755
Binary file not shown.
59 changes: 59 additions & 0 deletions js/js.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"bytes"
"fmt"
"syscall/js"

"github.com/abs-lang/abs/evaluator"
"github.com/abs-lang/abs/lexer"
"github.com/abs-lang/abs/object"
"github.com/abs-lang/abs/parser"
)

// Version of the ABS interpreter
var Version = "dev"

// This function takes ABS code
// and evaluates it, using a buffer
// to store it's output.
// Once the code is evaluated, both
// the output and the return value of
// the script are returned to js in the
// form of {out, result}.
func runCode(this js.Value, i []js.Value) interface{} {
m := make(map[string]interface{})
var buf bytes.Buffer
// the first argument to our function
code := i[0].String()
env := object.NewEnvironment(&buf, "", Version)
lex := lexer.New(code)
p := parser.New(lex)

program := p.ParseProgram()

if len(p.Errors()) != 0 {
printParserErrors(p.Errors(), buf)
m["out"] = buf.String()
return js.ValueOf(m)
}

result := evaluator.BeginEval(program, env, lex)
m["out"] = buf.String()
m["result"] = result.Inspect()

return js.ValueOf(m)
}

func printParserErrors(errors []string, buf bytes.Buffer) {
fmt.Fprintf(&buf, "%s", " parser errors:\n")
for _, msg := range errors {
fmt.Fprintf(&buf, "%s", "\t"+msg+"\n")
}
}

func main() {
c := make(chan struct{}, 0)
js.Global().Set("abs_run_code", js.FuncOf(runCode))
<-c
}

0 comments on commit 90d940f

Please sign in to comment.