Giter Site home page Giter Site logo

alholmbe-assembly's Introduction

Interpreter to BBVV

To run the program: Make sure that you have Go installed and then cd into the interpreter folder and type:

"go run . filename"

where filename can be e.g factorial.bbvv

alholmbe-assembly's People

Contributors

holma91 avatar

alholmbe-assembly's Issues

Pass

Very well done Alexander!

You are well set for DD1396! How sweet!

I like your solution! Thou I'm curious, why do you parse the code in string, and not use enum representations? Enum types are numerical, thus are a lot more efficient to compare etc. For example:
Your code:

var registerType = []string{"add", "sub", "set", "jeq"}
var jumpType = []string{"j"}
var specialType = []string{"input", "print", "exit"}

As enum types:

type RegisterInstr int
const (
	Add RegisterInstr = iota + 1
	Sub
	Set
	Jeq
)

type JumpInstr int
const J JumpInstr = 1

type SpecialInstr int
const (
	Input SpecialInstr = iota + 1
	Print
	Exit
)

See enum types: https://gosamples.dev/enum/

Your splitIntoLines makes it difficult to acctually trace errors. instructionsAreValid handles the instructions as if there are no empty lines in the source code, which there are. I even found this beauty :)
Your code:

var j int
for j = 1; j < 3; j++ {
	//...
	if /*...*/ {
		fmt.Printf("Error on line %d: Missing '#'\n", j+1)
		//...
	}
}

I suggest that the trimmer function returns a sequence of tuples, whom hold an instruction and the instruction's origin line.

Thank you for your hard work :)

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.