Giter VIP home page Giter VIP logo

gosh's People

Contributors

aleksi avatar bombsimon avatar linkleonard avatar mmiranda96 avatar mryadro avatar quasilyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gosh's Issues

REPL history is broken

Issue description

REPL history is not being saved between sessions.

Environment

  • Gosh version (commit hash if unreleased): v0.0.1
  • go env output: not relevant

Minimal test code / Steps to reproduce the issue

  1. Start gosh, type some code, exit.
  2. Start gosh again, hit up arrow.

What's the actual result? (include panic message & call stack if applicable)

Nothing.

What's the expected result?

The previous line of code is loaded from the history.

Sandboxing

We should implement an ability to sandbox the interpreter.

Add files to scanner

Extend scanner to handle several files.
Attach file names, line numbers, column numbers to tokens.

Expand contributing guidelines

Contributing guidelines should include:

  • local setup with modules and without them;
  • code style (gofmt -w -s ., make check).

Support switch statement

switch {
case m3 && m5:
	println("FizzBuzz")
case m3:
	println("Fizz")
case m5:
	println("Buzz")
default:
	println(i)
}

Renaming Gosh

Maybe Gosh is not a great name after all…
(note the issue number)

Add colors to REPL

Let's add basic colors to the REPL. Error messages should be in red and results should be in green. And there should be a flag to disable colors.

We probably should use github.com/fatih/color, but if there is something better – feel free to propose it.

`make check` shows errors

Issue description

make check shows errors. It shouldn't – we should either tweak linters configurations or fix code.

Environment

  • Gosh version (commit hash if unreleased): v0.0.1
  • go env output: not relevant.

Minimal test code / Steps to reproduce the issue

  1. Run make check.

What's the actual result? (include panic message & call stack if applicable)

go generate ./...
go install -v ./...
go run misc/check_license.go
golangci-lint run ./...
main.go:132: G304: Potential file inclusion via variable (gosec)
		f, err := os.Open(historyFilename)
main.go:170: G304: Potential file inclusion via variable (gosec)
	b, err := ioutil.ReadFile(filename)
internal/gofuzz/corpus.go:11: G505: Blacklisted import `crypto/sha1`: weak cryptographic primitive (gosec)
	"crypto/sha1"
internal/gofuzz/corpus.go:42: G401: Use of weak cryptographic primitive (gosec)
	name := fmt.Sprintf("%s-%040x.gosh", prefix, sha1.Sum(data))
internal/golden/golden.go:50: G304: Potential file inclusion via variable (gosec)
		tokens, err := ioutil.ReadFile(f + ".tokens")
main.go:135:21: Error return value of `liner.ReadHistory` is not checked (errcheck)
			liner.ReadHistory(f)
			                 ^
main.go:136:11: Error return value of `f.Close` is not checked (errcheck)
			f.Close()
			       ^
main.go:147:12: Error return value of `os.Create` is not checked (errcheck)
		os.Create(historyFilename)
		         ^
make: *** [check] Error 1

What's the expected result?

No errors.

Add CI check for generated files

Problem: generated files may not be up-to-date in the repository.

Solution: check that generated files are up-to-date in the CI.

That might be as simple as running git diff --exit-code after make install.

Fix scanner issues

Currently, go-fuzz finds crashers in the scanner. We should fix them.

Fuzzer for mathematical expressions

  1. Generate mathematical expression with integers and floats, and several operators and braces. For example:
42 + 7 / (13.0)
  1. Generate and run a small Go program to get an expression result or error. For example:
package main

import "fmt"

func main() {
    x := 42 + 7 / (13.0)
    fmt.Println(x)
}
  1. If there is no error, feed the same expression to Gosh and compare results.

For the first step, we may use go-fuzz with some initial corpus. Later we could create a custom code generator just for mathematical expressions. See also: #40.

Eval

Language should provide eval() function to evaluate a string of Gosh source code.

Goroutines and race detector

The language currently does not provides goroutines. Before introducing them we probably should implement some kind of Gosh-level race detector.

objects: consider using CamelCase instead of ALL_UPPER for constants

// The list of object types.
const (
-	INTEGER Type = iota
-	BOOLEAN
-	STRING
-	FUNCTION
-	GOFUNCTION
-	CONTINUE
+	Integer Type = iota
+	Boolean
+	String
+	Function
+	GoFunction
+	Continue
)

It may also require examples/tests update if anything depends on the stringer output for those.

Type checker

We should check types before evaluation.

We should do that before adding new language constructs like structs, methods, and interfaces.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.