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
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 :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.